FileDocCategorySizeDatePackage
OneToOneType.javaAPI DocHibernate 3.2.53995Mon Jul 25 01:53:10 BST 2005org.hibernate.type

OneToOneType

public class OneToOneType extends EntityType
A one-to-one association to an entity
author
Gavin King

Fields Summary
private final ForeignKeyDirection
foreignKeyType
private final String
propertyName
private final String
entityName
Constructors Summary
public OneToOneType(String referencedEntityName, ForeignKeyDirection foreignKeyType, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean isEmbeddedInXML, String entityName, String propertyName)

		super(
				referencedEntityName, 
				uniqueKeyPropertyName, 
				!lazy, 
				isEmbeddedInXML, 
				unwrapProxy
			);
		this.foreignKeyType = foreignKeyType;
		this.propertyName = propertyName;
		this.entityName = entityName;
	
Methods Summary
public java.lang.Objectassemble(java.io.Serializable oid, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		//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.getContextEntityIdentifier(owner), session, owner );
	
public java.io.Serializabledisassemble(java.lang.Object value, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		return null;
	
public intgetColumnSpan(org.hibernate.engine.Mapping session)

		return 0;
	
public ForeignKeyDirectiongetForeignKeyDirection()

		return foreignKeyType;
	
public java.lang.StringgetPropertyName()

		return propertyName;
	
public java.lang.Objecthydrate(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)


		return session.getContextEntityIdentifier(owner);
	
public booleanisAlwaysDirtyChecked()
We don't need to dirty check one-to-one because of how assemble/disassemble is implemented and because a one-to-one association is never dirty

		//TODO: this is kinda inconsistent with CollectionType
		return false; 
	
public booleanisDirty(java.lang.Object old, java.lang.Object current, org.hibernate.engine.SessionImplementor session)

		return false;
	
public booleanisDirty(java.lang.Object old, java.lang.Object current, boolean[] checkable, org.hibernate.engine.SessionImplementor session)

		return false;
	
public booleanisModified(java.lang.Object old, java.lang.Object current, boolean[] checkable, org.hibernate.engine.SessionImplementor session)

		return false;
	
public booleanisNull(java.lang.Object owner, org.hibernate.engine.SessionImplementor session)

		
		if ( propertyName != null ) {
			
			EntityPersister ownerPersister = session.getFactory()
					.getEntityPersister(entityName); 
			Serializable id = session.getContextEntityIdentifier(owner);

			EntityKey entityKey = new EntityKey( id, ownerPersister, session.getEntityMode() );
			
			return session.getPersistenceContext()
					.isPropertyNull( entityKey, getPropertyName() );
			
		}
		else {
			return false;
		}

	
protected booleanisNullable()

		return foreignKeyType==ForeignKeyDirection.FOREIGN_KEY_TO_PARENT;
	
public booleanisOneToOne()

		return true;
	
public voidnullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, boolean[] settable, org.hibernate.engine.SessionImplementor session)

		//nothing to do
	
public voidnullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.SessionImplementor session)

		//nothing to do
	
public int[]sqlTypes(org.hibernate.engine.Mapping session)

		return ArrayHelper.EMPTY_INT_ARRAY;
	
public boolean[]toColumnNullness(java.lang.Object value, org.hibernate.engine.Mapping mapping)

		return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
	
public booleanuseLHSPrimaryKey()

		return true;