我在java中有两个类,即txn和txnID,我想从嵌入式表中检索txnid值,下面是我的txn类结构:
public class TbTxn implements Serializable{
@EmbeddedId
private TbTxnId id;
private Long acctid;
private String hmbrchcd;
private String crdno;
//all the getter and setter code
}
这是嵌入式类结构:
@Embeddable
public class TbTxnId implements Serializable{
private Date txndttm;
private Long txnid;
@Column(name="TXNDTTM")
public Date getTxndttm() {
return txndttm;
}
public void setTxndttm(Date txndttm) {
this.txndttm = txndttm;
}
@Column(name="TXNID")
public Long getTxnid() {
return txnid;
}
public void setTxnid(Long txnid) {
this.txnid = txnid;
}
}
我的查询语句如下:
String stmt = "select txn.id.TXNID from TbTxn txn where txn.id.TXNDTTM >= SYSDATE ";
Long count = (Long) getSession().createQuery(stmt).uniqueResult();
以下错误消息:
SEVERE: Servlet.service() for servlet [] in context with path [] threw exception [Request processing failed; nested exception is
org.hibernate.QueryException: could not resolve property: id.TXNID of: com.domain.TbTxn [select txn.id.TXNID from com.domain.TbTxn txn where txn.id.TXNDTTM >= SYSDATE ]] with root cause
org.hibernate.QueryException: could not resolve property: id.TXNID of: com.domain.TbTxn [select txn.id.TXNID from com.domain.TbTxn txn where txn.id.TXNDTTM >= SYSDATE ]
答案 0 :(得分:0)
chair_f.scn
我们应该处理实体类名称及其属性的情况。