1 package org.hibernate.mapping; 3 4 import java.util.Iterator ; 5 6 import org.hibernate.MappingException; 7 import org.hibernate.engine.Mapping; 8 import org.hibernate.type.CollectionType; 9 import org.hibernate.type.TypeFactory; 10 11 16 public class Set extends Collection { 17 18 public void validate(Mapping mapping) throws MappingException { 19 super.validate( mapping ); 20 29 } 30 31 35 public Set(PersistentClass owner) { 36 super(owner); 37 } 38 39 public boolean isSet() { 40 return true; 41 } 42 43 public CollectionType getDefaultCollectionType() { 44 return isSorted() ? 45 TypeFactory.sortedSet( getRole(), getReferencedPropertyName(), isEmbedded(), getComparator() ) : 46 TypeFactory.set( getRole(), getReferencedPropertyName(), isEmbedded() ); 47 } 48 49 void createPrimaryKey() { 50 if ( !isOneToMany() ) { 51 PrimaryKey pk = new PrimaryKey(); 52 pk.addColumns( getKey().getColumnIterator() ); 53 Iterator iter = getElement().getColumnIterator(); 54 while ( iter.hasNext() ) { 55 Object selectable = iter.next(); 56 if ( selectable instanceof Column ) { 57 Column col = (Column) selectable; 58 if ( !col.isNullable() ) { 59 pk.addColumn(col); 60 } 61 } 62 } 63 if ( pk.getColumnSpan()==getKey().getColumnSpan() ) { 64 } 68 else { 69 getCollectionTable().setPrimaryKey(pk); 70 } 71 } 72 else { 73 } 75 } 76 77 public Object accept(ValueVisitor visitor) { 78 return visitor.accept(this); 79 } 80 } 81 | Popular Tags |