1 package org.hibernate.type; 3 4 import java.lang.reflect.Method ; 5 6 import org.hibernate.EntityMode; 7 import org.hibernate.FetchMode; 8 import org.hibernate.HibernateException; 9 import org.hibernate.MappingException; 10 import org.hibernate.engine.CascadeStyle; 11 import org.hibernate.engine.SessionImplementor; 12 import org.hibernate.tuple.ComponentTuplizer; 13 import org.hibernate.tuple.TuplizerLookup; 14 15 18 public class EmbeddedComponentType extends ComponentType { 19 20 public EmbeddedComponentType( 21 String [] propertyNames, 22 Type[] propertyTypes, 23 boolean[] nullabilities, 24 FetchMode[] joinedFetch, 25 CascadeStyle[] cascade, 26 boolean key, 27 TuplizerLookup tuplizers) 28 throws MappingException { 29 super( 30 propertyNames, 31 propertyTypes, 32 nullabilities, 33 joinedFetch, 34 cascade, 35 key, 36 tuplizers 37 ); 38 } 39 40 public boolean isMethodOf(Method method) { 41 return ( (ComponentTuplizer) tuplizers.getTuplizer(EntityMode.POJO) ).isMethodOf(method); 42 } 43 44 public Object instantiate(Object parent, SessionImplementor session) 45 throws HibernateException { 46 final boolean useParent = parent!=null && 47 super.getReturnedClass().isInstance(parent); 51 52 return useParent ? parent : super.instantiate(parent, session); 53 } 54 } 55 | Popular Tags |