Hibernate / JPA返回空值列表

时间:2013-09-18 03:22:58

标签: java hibernate list jpa null

我有一个这样的实体:

@Entity
@Table(name = "MY_TABLE")
public class OrderPackage implements Serializable { 

   @EmbeddedId
   @AttributeOverrides({ 
        @AttributeOverride(name = "pId", column = @Column(name = "P_ID")),
        @AttributeOverride(name = "prId", column = @Column(name = "PR_ID")),
        @AttributeOverride(name = "pin", column = @Column(name = "PIN")),
        @AttributeOverride(name = "Id", column = @Column(name = "MN_ID"))       
   })
   private PackageId id;

   @Column(name = "MEM_ID")
   private Long memberId;

    .....
    .....
   // more fields and getters and setters
}

PackageId.class

@Embeddable
public class PackageId implements Serializable {

   private String pId;
   private String prId;
   private String pin;
   private Long Id;

    // getters and setters
}

Mytable的以下字段与我的查询匹配:

SELECT c FROM OrderPackage c where <condition> order by c.prId;

匹配这样的记录:

  MN_ID     MEM_ID       P_ID            PR_ID           PIN       ///some other fields
  6217      402022795    A1000005361     B1000077615     (null)
  6213      402022795    A1000005361     B1000037615     (null)
  6218      402022795    A1000005361     B1000087615     (null)
  6215      402022795    A1000005361     B1000057615     (null)

MN_ID在这里是唯一的。

我得到了计数4.但是列表中的所有空行。

导致这种情况的原因是什么?

jBoss 4.2.x
JPA
Hibernate
ORACLE

更新

这仍然是这样吗? (当复合键中的任何一个字段都有空值时,它会为整个行返回null)

http://thelittlefellow.blogspot.com/2011/07/hibernate-gethibernatetemplatefind.html

https://hibernate.atlassian.net/browse/HHH-177

0 个答案:

没有答案