1 19 20 package org.apache.cayenne.jpa.reflect; 21 22 import org.apache.cayenne.map.ObjRelationship; 23 import org.apache.cayenne.reflect.Accessor; 24 import org.apache.cayenne.reflect.ClassDescriptor; 25 import org.apache.cayenne.reflect.ClassDescriptorMap; 26 import org.apache.cayenne.reflect.PersistentDescriptor; 27 import org.apache.cayenne.reflect.pojo.EnhancedPojoDescriptorFactory; 28 29 public class JpaClassDescriptorFactory extends EnhancedPojoDescriptorFactory { 30 31 public JpaClassDescriptorFactory(ClassDescriptorMap descriptorMap) { 32 super(descriptorMap); 33 } 34 35 @Override 36 protected void createToManyProperty( 37 PersistentDescriptor descriptor, 38 ObjRelationship relationship) { 39 ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship 40 .getTargetEntityName()); 41 String reverseName = relationship.getReverseRelationshipName(); 42 43 Accessor accessor = new JpaCollectionFieldAccessor( 44 descriptor.getObjectClass(), 45 relationship.getName(), 46 null); 47 descriptor.addDeclaredProperty(new JpaToManyProperty( 48 descriptor, 49 targetDescriptor, 50 accessor, 51 reverseName)); 52 } 53 } 54 | Popular Tags |