2016-11-23 87 views
0

Embedable类删除使用组合键休眠

@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:pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2Entity [删除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 [从pk.gov.fbr.insys.entity.workflow.WorkFlowTaskInterface2删除实体。实体WHERE实体。 interfaceCode = 58 AND entity.processRuleId = 112301]

回答

0

这里的问题非常讨人喜欢,从stacktrace。 interfaceCode属性在SaTaskInterfacesId中声明,并且此类不属于WorkFlowTaskInterface2Entity的父类,因此未找到该属性。