|
Hibernate example source code file (Node.java)
The Hibernate Node.java source code//$Id$ package org.hibernate.test.annotations.manytoone; import java.io.Serializable; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; /** * @author Emmanuel Bernard */ @Entity public class Node implements Serializable { private NodePk id; private String description; private Node parent; public boolean equals(Object o) { if ( this == o ) return true; if ( !( o instanceof Node ) ) return false; final Node node = (Node) o; if ( !id.equals( node.id ) ) return false; return true; } public int hashCode() { return id.hashCode(); } @Id public NodePk getId() { return id; } public void setId(NodePk id) { this.id = id; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parentName"), @JoinColumn(name = "parentLevel") }) public Node getParent() { return parent; } public void setParent(Node parent) { this.parent = parent; } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate Node.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.