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.util.JoinedIterator; 9 10 13 public class SingleTableSubclass extends Subclass { 14 15 public SingleTableSubclass(PersistentClass superclass) { 16 super(superclass); 17 } 18 19 protected Iterator getNonDuplicatedPropertyIterator() { 20 return new JoinedIterator( 21 getSuperclass().getUnjoinedPropertyIterator(), 22 getUnjoinedPropertyIterator() 23 ); 24 } 25 26 protected Iterator getDiscriminatorColumnIterator() { 27 if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) { 28 return getDiscriminator().getColumnIterator(); 29 } 30 else { 31 return super.getDiscriminatorColumnIterator(); 32 } 33 } 34 35 public Object accept(PersistentClassVisitor mv) { 36 return mv.accept(this); 37 } 38 39 public void validate(Mapping mapping) throws MappingException { 40 if(getDiscriminator()==null) { 41 throw new MappingException("No discriminator found for " + getEntityName() + ". Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses"); 42 } 43 super.validate(mapping); 44 } 45 } 46 | Popular Tags |