hibernate方便的操作数据库相当不错的 请各位下载看看啊

源代码在线查看: parent.java

软件大小: 195 K
上传用户: liu2000dz
关键词: hibernate 操作 数据库
下载地址: 免注册下载 普通下载 VIP

相关代码

				//$Id: Parent.java,v 1.3 2005/02/13 22:46:18 epbernard Exp $				package org.hibernate.test.metadata.onetomany;								import org.hibernate.annotations.BatchSize;								import javax.ejb.Entity;				import javax.ejb.AccessType;				import javax.ejb.Id;				import javax.ejb.OneToMany;				import javax.ejb.CascadeType;				import javax.ejb.JoinColumns;				import javax.ejb.JoinColumn;				import java.util.Collection;				import java.util.Set;				import java.util.HashSet;				import java.io.Serializable;								/**				 * @author Emmanuel Bernard				 */				@Entity(access = AccessType.FIELD)				public class Parent implements Serializable {					@Id					public ParentPk id;					public int age;										@OneToMany(cascade=CascadeType.ALL)					@JoinColumns ({						@JoinColumn(name="parentCivility", referencedColumnName = "isMale"),						@JoinColumn(name="parentLastName", referencedColumnName = "lastName"),						@JoinColumn(name="parentFirstName", referencedColumnName = "firstName")					})					@BatchSize(size=5)					public Set children;									public int hashCode() {						//a NPE can occurs, but I don't expect hashcode to be used before pk is set						return id.hashCode();					}									public boolean equals(Object obj) {						//a NPE can occurs, but I don't expect equals to be used before pk is set						if (obj != null && obj instanceof Parent) {							return id.equals( ( (Parent) obj).id );						}						else {							return false;						}					}									public void addChild(Child child) {						if (children == null) {							children = new HashSet();						}						child.parent = this;						children.add(child);					}				}							

相关资源