This was opened before in Hibernate Users, but was misplaced as this is about annotations. I've removed the topic there and opened it here.
Hello,
I'm testing the AccessType annotation and I've found that the following case does not work. Hibernate does not pick up the
@AccessType("field") (from the function in this case), but when placed on the property it also has no effect.
The unit tests for hibernate annotations do not cover this. Am I requesting something impossible?
Code:
@AccessType("propery")
public class Test()
{
private String test;
@AccessType("field")
public WeirdCollection getTest()
{
return new WeirdCollection( test );
}
}
The workaround is as follows (pretty specific for the above case). This is of course very undesirable and leads to an incredible amount of code bloat in more complex situations.
Code:
@AccessType("propery")
public class Test()
{
private String _test;
@Transient
public WeirdCollection getTest()
{
return new WeirdCollection( _test );
}
public String get_Test(){ return _test; }
pulbic void set_Test(String test) { this._test = test; }
}
Actually I wanted to use a @CollectionType annotation (which does not exist) to map the WeirdCollection to a List. The accesstype stuff was a hack around it, but it seems that the hack needs a hack...
Hibernate version:
Annotations 3.2.0
Hibernate 3.2.1
(both from Jboss 5 embeddable Beta 2)
Mapping documents:
None, all annotations
Code between sessionFactory.openSession() and session.close():
None, error occurs in loading and configuration
Full stack trace of any exception that occurs:
In this case an exception telling that the WierdCollection is not a Set or List as supported by hibernate