When I run this method, I get the following error:
Quote:
"org.hibernate.QueryException: could not resolve property: status.statusCode of: com.company.CmpsOrder"
.
Here is the query code:
Code:
Criteria query = session.createCriteria(CmpsOrder.class);
if ( divisionID != null && !divisionID.isEmpty()) {
query.add(Restrictions.eq("division.divisionId", divisionID));
}
query.add(Restrictions.eq("status.statusCode", stat));
query.addOrder(Order.desc("modificationDate"));
List<CmpsOrder> orderList = query.list();
Here is the relevant CpmsOrder code (with proper getters and setters):
Code:
@Entity
@Table(name="CMS_ORDER")
public class CmpsOrder
{
private ClientPlatform division;
private CmpsOrderStatus status;
private Date modificationDate = new Date();
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="DIVISION_ID")
public ClientPlatform getDivision() {
return this.division;
}
public void setDivision(ClientPlatform x) {
this.division = x;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="STATUS_ID")
public CmpsOrderStatus getStatus() {
return this.status;
}
public void setStatus(CmpsOrderStatus x) {
this.status = x;
}
@Column(name="MODIFICATION_DATE")
public Date getModificationDate() {
return this.modificationDate;
}
public void setModificationDate(Date x) {
this.modificationDate = x;
}
}
And here is the CmpsOrderStatus code:
Code:
@Entity
@Table(name="CMS_ORDER_STATUS")
public class CmpsOrderStatus {
private long statusID;
private String statusCode;
private String description;
@Id
@Column(name="STATUS_ID")
public long getStatusID() {
return statusID;
}
public void setStatusID(long id) {
this.statusID = id;
}
@Column(name="STATUS_CODE")
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String code) {
this.statusCode = code;
}
@Column(name="DESCRIPTION")
public String getDescription() {
return description;
}
public void setDescription(String desc) {
this.description = desc;
}
}
What am I missing or doing wrong?