⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onetoonetype.java

📁 介绍了hibernate的入门有一些基本常用的事例
💻 JAVA
字号:
//$Id: OneToOneType.java,v 1.16 2005/04/03 15:55:03 oneovthafew Exp $package org.hibernate.type;import java.io.Serializable;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import org.hibernate.HibernateException;import org.hibernate.MappingException;import org.hibernate.engine.Mapping;import org.hibernate.engine.SessionImplementor;import org.hibernate.util.ArrayHelper;/** * A one-to-one association to an entity * @author Gavin King */public class OneToOneType extends EntityType {	private final ForeignKeyDirection foreignKeyType;	public int getColumnSpan(Mapping session) throws MappingException {		return 0;	}	public int[] sqlTypes(Mapping session) throws MappingException {		return ArrayHelper.EMPTY_INT_ARRAY;	}	public OneToOneType(			String entityName, 			ForeignKeyDirection foreignKeyType, 			String uniqueKeyPropertyName, 			boolean isEmbeddedInXML	) {		super(entityName, uniqueKeyPropertyName, isEmbeddedInXML);		this.foreignKeyType = foreignKeyType;	}	public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) {		//nothing to do	}	public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) {		//nothing to do	}	public boolean isOneToOne() {		return true;	}	public boolean isDirty(Object old, Object current, SessionImplementor session) {		return false;	}	public boolean isModified(Object old, Object current, SessionImplementor session) {		return false;	}	public ForeignKeyDirection getForeignKeyDirection() {		return foreignKeyType;	}	public Object hydrate(		ResultSet rs,		String[] names,		SessionImplementor session,		Object owner)	throws HibernateException, SQLException {		return session.getEntityIdentifier(owner);	}	protected boolean isNullable() {		return foreignKeyType==ForeignKeyDirection.FOREIGN_KEY_TO_PARENT;	}	public boolean useLHSPrimaryKey() {		return true;	}	public Serializable disassemble(Object value, SessionImplementor session, Object owner)	throws HibernateException {		return null;	}	public Object assemble(Serializable oid, SessionImplementor session, Object owner)	throws HibernateException {		//this should be a call to resolve(), not resolveIdentifier(), 		//'cos it might be a property-ref, and we did not cache the		//referenced value		return resolve( session.getEntityIdentifier(owner), session, owner );	}		public boolean isAlwaysDirtyChecked() {		return false; 		// because of how assemble/disassemble is implemented		// and because one-to-one is never dirty		//TODO: this is kinda inconsistent with CollectionType	}	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -