|
Hibernate example source code file (ManPk.java)
The Hibernate ManPk.java source code//$Id$ package org.hibernate.test.annotations.manytomany; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Embeddable; /** * @author Emmanuel Bernard */ @Embeddable public class ManPk implements Serializable { private String firstName; private String lastName; private boolean isElder; public boolean isElder() { return isElder; } public void setElder(boolean elder) { isElder = elder; } public int hashCode() { //this implem sucks return getFirstName().hashCode() + getLastName().hashCode() + ( isElder() ? 0 : 1 ); } public boolean equals(Object obj) { //firstName and lastName are expected to be set in this implem if ( obj != null && obj instanceof ManPk ) { ManPk other = (ManPk) obj; return getFirstName().equals( other.getFirstName() ) && getLastName().equals( other.getLastName() ) && isElder() == other.isElder(); } else { return false; } } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } @Column(length=128) public String getFirstName() { return firstName; } @Column(length=128) public String getLastName() { return lastName; } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate ManPk.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.