KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > mapping > SingleTableSubclass


1 //$Id: SingleTableSubclass.java,v 1.5 2005/06/22 17:02:26 turin42 Exp $
2
package org.hibernate.mapping;
3
4 import java.util.Iterator JavaDoc;
5
6 import org.hibernate.MappingException;
7 import org.hibernate.engine.Mapping;
8 import org.hibernate.util.JoinedIterator;
9
10 /**
11  * @author Gavin King
12  */

13 public class SingleTableSubclass extends Subclass {
14     
15     public SingleTableSubclass(PersistentClass superclass) {
16         super(superclass);
17     }
18     
19     protected Iterator JavaDoc getNonDuplicatedPropertyIterator() {
20         return new JoinedIterator(
21                 getSuperclass().getUnjoinedPropertyIterator(),
22                 getUnjoinedPropertyIterator()
23         );
24     }
25     
26     protected Iterator JavaDoc getDiscriminatorColumnIterator() {
27         if ( isDiscriminatorInsertable() && !getDiscriminator().hasFormula() ) {
28             return getDiscriminator().getColumnIterator();
29         }
30         else {
31             return super.getDiscriminatorColumnIterator();
32         }
33     }
34
35     public Object JavaDoc 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