我有一个这样的实体:
@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
更新:
现在还是这样吗?(当复合键中的任何一个字段为空值时,它会为整行返回空值)
http://thelittlefellow.blogspot.com/2011/07/hibernate-gethibernatetemplatefind.html