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.engine.SessionImplementor; 9 import org.hibernate.engine.SessionFactoryImplementor; 10 11 16 public class IndexPropertyAccessor implements PropertyAccessor { 17 18 private final String propertyName; 19 private final String entityName; 20 21 26 public IndexPropertyAccessor(String collectionRole, String entityName) { 27 this.propertyName = collectionRole.substring( entityName.length()+1 ); 28 this.entityName = entityName; 29 } 30 31 public Setter getSetter(Class theClass, String propertyName) { 32 return new IndexSetter(); 33 } 34 35 public Getter getGetter(Class theClass, String propertyName) { 36 return new IndexGetter(); 37 } 38 39 40 43 public static final class IndexSetter implements Setter { 44 45 public Method getMethod() { 46 return null; 47 } 48 49 public String getMethodName() { 50 return null; 51 } 52 53 public void set(Object target, Object value) { 54 } 56 57 public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { 58 } 60 61 } 62 63 64 67 public class IndexGetter implements Getter { 68 69 public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException { 70 if (session==null) { 71 return BackrefPropertyAccessor.UNKNOWN; 72 } 73 else { 74 return session.getPersistenceContext() 75 .getIndexInOwner(entityName, propertyName, target, mergeMap); 76 } 77 } 78 79 public Object get(Object target) { 80 return BackrefPropertyAccessor.UNKNOWN; 81 } 82 83 public Method getMethod() { 84 return null; 85 } 86 87 public String getMethodName() { 88 return null; 89 } 90 91 public Class getReturnType() { 92 return Object .class; 93 } 94 } 95 } 96 | Popular Tags |