FileDocCategorySizeDatePackage
OneToOne.javaAPI DocHibernate 3.2.53300Mon Jun 20 15:32:36 BST 2005org.hibernate.mapping

OneToOne

public class OneToOne extends ToOne
A one-to-one association mapping
author
Gavin King

Fields Summary
private boolean
constrained
private org.hibernate.type.ForeignKeyDirection
foreignKeyType
private KeyValue
identifier
private String
propertyName
private String
entityName
Constructors Summary
public OneToOne(Table table, PersistentClass owner)

		super(table);
		this.identifier = owner.getKey();
		this.entityName = owner.getEntityName();
	
Methods Summary
public java.lang.Objectaccept(ValueVisitor visitor)

		return visitor.accept(this);
	
public voidcreateForeignKey()

		if ( constrained && referencedPropertyName==null) {
			//TODO: handle the case of a foreign key to something other than the pk
			createForeignKeyOfEntity( ( (EntityType) getType() ).getAssociatedEntityName() );
		}
	
public java.util.ListgetConstraintColumns()

		ArrayList list = new ArrayList();
		Iterator iter = identifier.getColumnIterator();
		while ( iter.hasNext() ) list.add( iter.next() );
		return list;
	
public java.lang.StringgetEntityName()

		return entityName;
	
public org.hibernate.type.ForeignKeyDirectiongetForeignKeyType()
Returns the foreignKeyType.

return
AssociationType.ForeignKeyType

		return foreignKeyType;
	
public KeyValuegetIdentifier()
Returns the identifier.

return
Value

		return identifier;
	
public java.lang.StringgetPropertyName()

		return propertyName;
	
public org.hibernate.type.TypegetType()

		if ( getColumnIterator().hasNext() ) {
			return new SpecialOneToOneType(
					getReferencedEntityName(), 
					foreignKeyType, 
					referencedPropertyName,
					isLazy(),
					isUnwrapProxy(),
					entityName,
					propertyName
				);
		}
		else {
			return TypeFactory.oneToOne( 
					getReferencedEntityName(), 
					foreignKeyType, 
					referencedPropertyName,
					isLazy(),
					isUnwrapProxy(),
					isEmbedded(),
					entityName,
					propertyName
				);
		}
	
public booleanisConstrained()
Returns the constrained.

return
boolean

		return constrained;
	
public booleanisNullable()

		return !constrained;
	
public voidsetConstrained(boolean constrained)
Sets the constrained.

param
constrained The constrained to set

		this.constrained = constrained;
	
public voidsetEntityName(java.lang.String propertyName)

		this.entityName = entityName==null ? null : entityName.intern();
	
public voidsetForeignKeyType(org.hibernate.type.ForeignKeyDirection foreignKeyType)
Sets the foreignKeyType.

param
foreignKeyType The foreignKeyType to set

		this.foreignKeyType = foreignKeyType;
	
public voidsetIdentifier(KeyValue identifier)
Sets the identifier.

param
identifier The identifier to set

		this.identifier = identifier;
	
public voidsetPropertyName(java.lang.String propertyName)

		this.propertyName = propertyName==null ? null : propertyName.intern();