可嵌入班级
@Embeddable
public class SaTaskInterfacesId implements java.io.Serializable {
// Fields
/**
*
*/
private static final long serialVersionUID = -4070669691040083979L;
private Long processRuleId;
private Long interfaceCode;
// Constructors
/** default constructor */
public SaTaskInterfacesId() {
}
/** full constructor */
public SaTaskInterfacesId(Long processRuleId, Long interfaceCode) {
this.processRuleId = processRuleId;
this.interfaceCode = interfaceCode;
}
// Property accessors
@Column(name = "PROCESS_RULE_ID")
public Long getProcessRuleId() {
return this.processRuleId;
}
public void setProcessRuleId(Long processRuleId) {
this.processRuleId = processRuleId;
}
@Column(name = "INTERFACE_CODE")
public Long getInterfaceCode() {
return this.interfaceCode;
}
public void setInterfaceCode(Long interfaceCode) {
this.interfaceCode = interfaceCode;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof SaTaskInterfacesId))
return false;
SaTaskInterfacesId castOther = (SaTaskInterfacesId) other;
return ((this.getProcessRuleId() == castOther.getProcessRuleId()) || (this
.getProcessRuleId() != null
&& castOther.getProcessRuleId() != null && this
.getProcessRuleId().equals(castOther.getProcessRuleId())))
&& ((this.getInterfaceCode() == castOther.getInterfaceCode()) || (this
.getInterfaceCode() != null
&& castOther.getInterfaceCode() != null && this
.getInterfaceCode()
.equals(castOther.getInterfaceCode())));
}
public int hashCode() {
int result = 17;
result = 37
* result
+ (getProcessRuleId() == null ? 0 : this.getProcessRuleId()
.hashCode());
result = 37
* result
+ (getInterfaceCode() == null ? 0 : this.getInterfaceCode()
.hashCode());
return result;
}
}
Entity Class
@Entity
@Table(name = "SA_TASK_INTERFACES")
public class WorkFlowTaskInterface2Entity extends BaseEntity {
private SaTaskInterfacesId id;
// private Long saWorkflowRules;
private Short sortOrder;
private String itemCsv;
private String personCodeCsv;
// Property accessors
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name = "processRuleId", column = @Column(name = "PROCESS_RULE_ID" )),
@AttributeOverride(name = "interfaceCode", column = @Column(name = "INTERFACE_CODE" )) })
public SaTaskInterfacesId getId() {
return this.id;
}
public void setId(SaTaskInterfacesId id) {
this.id = id;
}
@Column(name = "SORT_ORDER" )
public Short getSortOrder() {
return this.sortOrder;
}
public void setSortOrder(Short sortOrder) {
this.sortOrder = sortOrder;
}
@Column(name = "ITEM_CSV", length = 50)
public String getItemCsv() {
return this.itemCsv;
}
public void setItemCsv(String itemCsv) {
this.itemCsv = itemCsv;
}
@Column(name = "PERSON_CODE_CSV", length = 150)
public String getPersonCodeCsv() {
return this.personCodeCsv;
}
public void setPersonCodeCsv(String personCodeCsv) {
this.personCodeCsv = personCodeCsv;
}
}
Deletion Query Sample
public void taskInterfaceDeletion(WorkFlowTaskInterface2Entity workFlowTaskInterface2Entity) {
baseORMDao.executeQuery("DELETE FROM WorkFlowTaskInterface2Entity entity WHERE entity.interfaceCode="+(long)58+" AND entity.processRuleId="+(long)112301+"");
}
错误是:
无法解析属性:interfaceCode of:pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2Entity [DELETE FROM pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2Entity entity WHERE entity.interfaceCode = 58 AND entity。 processRuleId = 112301];嵌套异常是org.hibernate.QueryException:无法解析属性:interfaceCode:pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2Entity [DELETE FROM pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2Entity entity WHERE entity。 interfaceCode = 58 AND entity.processRuleId = 112301]
答案 0 :(得分:0)
这里的问题从堆栈跟踪中非常明显。 interfaceCode
属性在SaTaskInterfacesId
中声明,此类不是WorkFlowTaskInterface2Entity
的父类,因此找不到该属性。