|
Hibernate example source code file (Sickness.java)
The Hibernate Sickness.java source codepackage org.hibernate.ejb.test.util; import java.io.Serializable; import java.util.Date; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.Temporal; /** * @author Emmanuel Bernard */ @Entity @IdClass(Sickness.PK.class) public class Sickness { private Date beginTime; private String type; private String classification; @Id public String getType() { return type; } public void setType(String type) { this.type = type; } @Id public String getClassification() { return classification; } public void setClassification(String classification) { this.classification = classification; } @Temporal(javax.persistence.TemporalType.DATE) public Date getBeginTime() { return beginTime; } public void setBeginTime(Date beginTime) { this.beginTime = beginTime; } public static class PK implements Serializable { private String type; private String classification; public String getType() { return type; } public void setType(String type) { this.type = type; } public String getClassification() { return classification; } public void setClassification(String classification) { this.classification = classification; } @Override public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } PK pk = ( PK ) o; if ( classification != null ? !classification.equals( pk.classification ) : pk.classification != null ) { return false; } if ( type != null ? !type.equals( pk.type ) : pk.type != null ) { return false; } return true; } @Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + ( classification != null ? classification.hashCode() : 0 ); return result; } } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate Sickness.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.