FileDocCategorySizeDatePackage
ManyToOne.javaAPI DocHibernate 3.2.52377Wed Jul 20 20:11:52 BST 2005org.hibernate.mapping

ManyToOne

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

Fields Summary
private boolean
ignoreNotFound
Constructors Summary
public ManyToOne(Table table)

		super(table);
	
Methods Summary
public java.lang.Objectaccept(ValueVisitor visitor)

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

		// the case of a foreign key to something other than the pk is handled in createPropertyRefConstraints
		if (referencedPropertyName==null && !hasFormula() ) {
			createForeignKeyOfEntity( ( (EntityType) getType() ).getAssociatedEntityName() );
		} 
	
public voidcreatePropertyRefConstraints(java.util.Map persistentClasses)

		if (referencedPropertyName!=null) {
			PersistentClass pc = (PersistentClass) persistentClasses.get(getReferencedEntityName() );
			
			Property property = pc.getReferencedProperty( getReferencedPropertyName() );
			
			if (property==null) {
				throw new MappingException(
						"Could not find property " + 
						getReferencedPropertyName() + 
						" on " + 
						getReferencedEntityName() 
					);
			} 
			else {
				if ( !hasFormula() && !"none".equals( getForeignKeyName() ) ) {
					java.util.List refColumns = new ArrayList();
					Iterator iter = property.getColumnIterator();
					while ( iter.hasNext() ) {
						Column col = (Column) iter.next();
						refColumns.add( col );							
					}
					
					ForeignKey fk = getTable().createForeignKey( 
							getForeignKeyName(), 
							getConstraintColumns(), 
							( (EntityType) getType() ).getAssociatedEntityName(), 
							refColumns 
						);
					fk.setCascadeDeleteEnabled(isCascadeDeleteEnabled() );
				}
			}
		}
	
public org.hibernate.type.TypegetType()

		return TypeFactory.manyToOne( 
				getReferencedEntityName(), 
				getReferencedPropertyName(),
				isLazy(),
				isUnwrapProxy(),
				isEmbedded(),
				isIgnoreNotFound()
			);
	
public booleanisIgnoreNotFound()

		return ignoreNotFound;
	
public voidsetIgnoreNotFound(boolean ignoreNotFound)

		this.ignoreNotFound = ignoreNotFound;