I posted the problem on the Hibernate-forum (https://forum.hibernate.org/viewtopic.php?f=1&t=1003277) and got no answer. So I assume this is a bug.
I wrote a custom PropertyAccessor {code} public class MyPropertyAccessor implements PropertyAccessor{code}
with this code within the set-Method of the Setter: {code} public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try {
if (((List) value) == null) { return; }
List tempList = new ArrayList(); tempList.addAll((List) value);
// ... more code here{code}
What I get during runtime is a "LazyInitializationException: illegal access to loading collection" (Stacktrace see below.).
IMHO Hibernate shouldn't give me an uninitialized value (AbstractPersistentCollection) into the set-method of the PropertyAccessor!? (Hibernate should assume that I want to do something with the collection before setting it to the entity!)
If I don't got the concept of a PropertyAccessor completely wrong, the "set"-flow should work like this:
1.) (Hibernate-Core) Load the data from Database (completely*), transform it to a value of the matching type (e.g. List) and hand it over to the PropertyAccessor. 2.) (PropertyAccessor) Receive the (completely*) loaded and transformed value, do whatever modification is necessary and set the result to the entity.
completely*: In case of FetchType.EAGER: Completely loaded / in case of FetchType.LAZY: "Ready to access".
Correct me if I got something wrong here.
BTW: The corresponding List-property of the entity is FetchType.EAGER: {code} @OneToMany (fetch = FetchType.EAGER) @Cascade ({CascadeType.ALL}) @JoinColumn(name="ParentId") @IndexColumn(name="ParentIndex") @AccessType(value="path.to.MyPropertyAccessor") private List<Foo> fooList;{code}
(and the Hibernate-session should also be alive at the moment of the Exception)
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________ hibernate-issues mailing list hibernate-issues@(protected) https://lists.jboss.org/mailman/listinfo/hibernate-issues