I have two classes (i.e. I removed the mapped attributes to the dbase columns to keep it short):
@Entity @Table(name = "Appeal_Header") public class AppealHeader implements Serializable { private static final long serialVersionUID = -8402922611571578104L; @Id @Column(name = "Appeal_Header_Key", unique=true, nullable=false) private long id;
@Column(name = "customer_cd", unique=true, nullable=false) private String customer;
@ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="hes_invoice_header_id", insertable=false, updatable=false, nullable=false) private BillingHeader billingHeader; public long getId() { return id; }
public void setId(long id) { this.id = id; }
public BillingHeader getBillingHeader() { return billingHeader; }
public void setBillingHeader(BillingHeader billingHeader) { this.billingHeader = billingHeader; }
public String getCustomer() { return customer; }
public void setCustomer(String customer) { this.customer = customer; }
}
@Entity @Table(name = "billing_header") public class BillingHeader implements Serializable { private static final long serialVersionUID = 503665425710114912L;
@Id @Column(name="hes_invoice_header_id", insertable=false, updatable=false, unique=true, nullable=false) private long id; @Column(name="claim_number", insertable=false, updatable=false, unique=false, nullable=false) private String claimNumber; @OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="hes_invoice_header_id", insertable=false, updatable=false, nullable=false) private List<AppealHeader> appealHeader; public long getId() { return id; }
public void setId(long id) { this.id = id; }
public String getClaimNumber() { return claimNumber; }
public void setClaimNumber(String claimNumber) { this.claimNumber = claimNumber; }
public List<AppealHeader> getAppealHeader() { return appealHeader; }
public void setAppealHeader(List<AppealHeader> appealHeader) { this.appealHeader = appealHeader; } }
Now, I'm executing this criteria query:
Criteria criteria = session.createCriteria(AppealHeader.class); if(!"".equals(form.getCustomer())) criteria.add(Restrictions.eq("customer",form.getCustomer())); if(!"".equals(form.getClaimNumber())) criteria.add(Restrictions.eq("billingHeader.claimNumber",form.getClaimNumber()));
If I query by customer I get back all the appeal header records plus the associated billing headers. But if I query by customer and billingHeader.claimNumber of just billingHeader.claimNumber alone. I get this exception:
org.hibernate.QueryException: could not resolve property: billingHeader.claimNumber of: healthe.appeals.model.AppealHeader
Can anybody help me out please??
Thanks!
|