我试图执行一个非常基本的查询并且我收到 org.hibernate.QueryException: could not resolve property。这是我的实体:
@Entity
@Table(name = "pm_screenconfiguration") 公共类 ScreenConfiguration 扩展 PubliMovilEntity {
/**
* serial.
*/
private static final long serialVersionUID = -5337034940299810600L;
@Id
@Column(name = "code")
private String code;
@Id
@Column(name = "companyCode")
private int companyCode;
@Id
@Column(name = "applicationId")
private int applicationId;
@Column(name = "value")
private String value;
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
/**
* @return the companyCode
*/
public int getCompanyCode() {
return companyCode;
}
/**
* @param companyCode the companyCode to set
*/
public void setCompanyCode(int companyCode) {
this.companyCode = companyCode;
}
/**
* @return the applicationId
*/
public int getApplicationId() {
return applicationId;
}
/**
* @param applicationId the applicationId to set
*/
public void setApplicationId(int applicationId) {
this.applicationId = applicationId;
}
}
这是我的查询:
public List<BaseEntity> getList(BaseSearchCriteria searchCriteria) {
Criteria criteria = getSessionFactory() .openSession().createCriteria(ScreenConfiguration.class);
if (searchCriteria.getApplicationId() != null) {
criteria.add(Restrictions.eq("applicationId", searchCriteria.getApplicationId()));
}
if (searchCriteria.getCompanyCode() != null) {
criteria.add(Restrictions.eq("companyCode", searchCriteria.getCompanyCode()));
}
return criteria.list();
}
我实在想不通。我使用 MySql 并且所有列都具有相同的实体名称。
谢谢。