1 package org.hibernate.cfg; 3 4 import java.lang.reflect.AnnotatedElement ; 5 import javax.persistence.Inheritance; 6 import javax.persistence.InheritanceType; 7 import javax.persistence.EmbeddableSuperclass; 8 import javax.persistence.AccessType; 9 10 15 public class InheritanceState { 16 public boolean hasSons = false; 17 public boolean hasParents = false; 18 public boolean hasEmbeddedSuperclass = false; 19 public InheritanceType type; 20 public boolean isEmbeddableSuperclass = false; 21 22 public AccessType accessType = null; 23 24 public void setInheritanceType(AnnotatedElement clazz) { 25 Inheritance inhAnn = clazz.getAnnotation(Inheritance.class); 26 EmbeddableSuperclass superclassAnn = clazz.getAnnotation( EmbeddableSuperclass.class ); 27 if ( superclassAnn != null ) { 28 isEmbeddableSuperclass = true; 29 type = inhAnn == null ? null : inhAnn.strategy(); 30 accessType = superclassAnn.access(); 31 } 32 else { 33 type = inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy(); 34 } 35 } 36 37 boolean hasTable() { 38 return !hasParents || !InheritanceType.SINGLE_TABLE.equals(type); 39 } 40 41 boolean hasDenormalizedTable() { 42 return hasParents && InheritanceType.TABLE_PER_CLASS.equals(type); 43 } 44 } 45 | Popular Tags |