I'm trying to use a custom PropertyAccessor and have a problem. The API assumes that I can provide a Getter/Setter given just the class and property name. For a reflection based accessor, this makes perfect sense. However, Hibernate lets you map entities with an entity-name, and you can even have multiple entities with the same class that have different properties.
This is what I'm doing - creating entities that share an implementing class, but have custom properties added so that each entity can be different. Each such entity has a unique entity-name specified.
For this to work properly with a custom PropertyAccessor, the API ought to be something like:
Code:
public interface PropertyAccessor {
public Getter getGetter(Class theClass, String entityName, String propertyName) throws PropertyNotFoundException;
public Setter getSetter(Class theClass, String entityName, String propertyName) throws PropertyNotFoundException;
}
instead of the current
Code:
public interface PropertyAccessor {
public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException;
public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException;
}
I can probably provide myself with a work-around by patching my local PropertyAccessorFactory, so that I can specify a custom class
and a custom value to be passed in to my PropertyAccessor constructor, but changing the PropertyAccessor API would be a better way to do this (from my perspective).
Is such a change possible?
Thanks,
Paul