1 package org.hibernate.property; 3 4 import java.lang.reflect.Method ; 5 import java.util.Map ; 6 7 import org.hibernate.HibernateException; 8 import org.hibernate.PropertyNotFoundException; 9 import org.hibernate.engine.SessionImplementor; 10 import org.hibernate.engine.SessionFactoryImplementor; 11 12 15 public class EmbeddedPropertyAccessor implements PropertyAccessor { 16 17 public static final class EmbeddedGetter implements Getter { 18 19 private final Class clazz; 20 21 EmbeddedGetter(Class clazz) { 22 this.clazz = clazz; 23 } 24 25 public Object get(Object target) throws HibernateException { 26 return target; 27 } 28 29 public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { 30 return get( target ); 31 } 32 33 public Method getMethod() { 34 return null; 35 } 36 37 public String getMethodName() { 38 return null; 39 } 40 41 public Class getReturnType() { 42 return clazz; 43 } 44 45 public String toString() { 46 return "EmbeddedGetter(" + clazz.getName() + ')'; 47 } 48 } 49 50 public static final class EmbeddedSetter implements Setter { 51 52 private final Class clazz; 53 54 EmbeddedSetter(Class clazz) { 55 this.clazz = clazz; 56 } 57 58 public Method getMethod() { 59 return null; 60 } 61 62 public String getMethodName() { 63 return null; 64 } 65 66 public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {} 67 68 public String toString() { 69 return "EmbeddedSetter(" + clazz.getName() + ')'; 70 } 71 } 72 73 public Getter getGetter(Class theClass, String propertyName) 74 throws PropertyNotFoundException { 75 return new EmbeddedGetter(theClass); 76 } 77 78 public Setter getSetter(Class theClass, String propertyName) 79 throws PropertyNotFoundException { 80 return new EmbeddedSetter(theClass); 81 } 82 83 } 84 | Popular Tags |