KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > type > EmbeddedComponentType


1 //$Id: EmbeddedComponentType.java,v 1.8 2005/06/20 07:41:31 oneovthafew Exp $
2
package org.hibernate.type;
3
4 import java.lang.reflect.Method JavaDoc;
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 /**
16  * @author Gavin King
17  */

18 public class EmbeddedComponentType extends ComponentType {
19
20     public EmbeddedComponentType(
21             String JavaDoc[] 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 JavaDoc method) {
41         return ( (ComponentTuplizer) tuplizers.getTuplizer(EntityMode.POJO) ).isMethodOf(method);
42     }
43     
44     public Object JavaDoc instantiate(Object JavaDoc parent, SessionImplementor session)
45     throws HibernateException {
46         final boolean useParent = parent!=null &&
47             //TODO: Yuck! This is not quite good enough, it's a quick
48
//hack around the problem of having a to-one association
49
//that refers to an embedded component:
50
super.getReturnedClass().isInstance(parent);
51         
52         return useParent ? parent : super.instantiate(parent, session);
53     }
54 }
55
Popular Tags