Hi
We are migrating from Hibernate 3.2.0.GA to 3.6.0.Final.
We use annotations to define mapping of persistence objects and encountered a problem with our use of @AccessType. Regular fields are accessed using Hibernate's default accessor, but collection fields we want to access using our own implementation of PropertyAccessor. Here is a snapshot of how we use annotations to define such a field:
Code:
@OneToMany(mappedBy="ownerObject",
targetEntity=targetEntityClassName.class)
@org.hibernate.annotations.AccessType("myPropertyAccessorImpl")
protected Set getCollectionField()
{
...
}
When debugging our application using Hibernate 3.6.0 we don't stop at our property accessor. Doing some debug on Hibernate code we've noticed that during Configuration.buildSessionFactory() (line 1826) we get to AnnotationBinder.processElementAnnotations() (line 1753), which calls collectionBinder.setAccessType( inferredData.getDefaultAccess() );
Now, PropertyInferredData.getDefaultAccess() gets the correct value from the annotation object but then calls AccessType.getAccessStrategy(accessTypeAnnotation.value()) (line 75), which translates it to the default accessor.
Are we doing something wrong? Is there another way of defining a custom property accessor using annotations?