|
Hibernate example source code file (ChildPk.java)
The Hibernate ChildPk.java source code//$Id$ package org.hibernate.test.annotations.cid; import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; /** * Child Pk with many to one inside * * @author Emmanuel Bernard */ @Embeddable public class ChildPk implements Serializable { public int nthChild; @ManyToOne() @JoinColumns({ @JoinColumn(name = "parentLastName", referencedColumnName = "p_lname", nullable = false), @JoinColumn(name = "parentFirstName", referencedColumnName = "firstName", nullable = false) }) public Parent parent; public boolean equals(Object o) { if ( this == o ) return true; if ( !( o instanceof ChildPk ) ) return false; final ChildPk childPk = (ChildPk) o; if ( nthChild != childPk.nthChild ) return false; if ( !parent.equals( childPk.parent ) ) return false; return true; } public int hashCode() { int result; result = nthChild; result = 29 * result + parent.hashCode(); return result; } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate ChildPk.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.