视图类:
import javax.persistence.Entity;import javax.persistence.Id;import javax.persistence.IdClass;@Entity@IdClass(VW_App_key.class)public class VW_App_Lab_Aux_Vwbasic { private Integer ap_id; private Integer ap_c_id; private String Project2; private String Au_SickMark; @Id public Integer getAp_id() { return ap_id; } public void setAp_id(Integer apId) { ap_id = apId; } public Integer getAp_c_id() { return ap_c_id; } public void setAp_c_id(Integer apCId) { ap_c_id = apCId; } @Id public String getProject2() { return Project2; } public void setProject2(String project2) { Project2 = project2; } public String getAu_SickMark() { return Au_SickMark; } public void setAu_SickMark(String auSickMark) { Au_SickMark = auSickMark; } }
联合主键类:
import java.io.Serializable;import javax.persistence.Embeddable;@Embeddable public class VW_App_key implements Serializable{//联合主键(VW_App_Lab_Aux_Vwbasic) private static final long serialVersionUID = -3304319243957837925L; private Integer ap_id; private String Project2; public Integer getAp_id() { return ap_id; } public void setAp_id(Integer apId) { ap_id = apId; } public String getProject2() { return Project2; } public void setProject2(String project2) { Project2 = project2; } @Override public boolean equals(Object o) { if(o instanceof VW_App_Lab_Aux_Vwbasic){ VW_App_Lab_Aux_Vwbasic key = (VW_App_Lab_Aux_Vwbasic)o ; if(this.ap_id == key.getAp_id() && this.Project2.equals(key.getProject2())){ return true ; } } return false ; } @Override public int hashCode() { return this.Project2.hashCode(); }}