Open GoogleCodeExporter opened 9 years ago
It seems that you are trying to replace a collection property of an entity that
did not have that property loaded. At least this seems to be the case when
PreCollectionRemoveEvent event is thrown from hibernate and its collection
property is null. Although it is a valid Hibernate case (e.g. replace the
collection even when the collection was not loaded) from hibernate audit
perspective we have to know at least the collection property name in order to
record anything. The property name for the collection is obtained from the
collection persister and this is not provided directly from the
PreCollectionRemoveEvent neither the collection role (which holds also what is
the property name) - hence the only way we can obtain that information is to
get the collection persister from the session by passing the persistence
collection - which in this case is null and because of that it throws NPE. Now
we have either to get that information (role name/property name - as minimum)
or we have to ignore the event when the collection is null which is also not a
very good thing. Now if Hibernate changes the PreCollectionRemoveEvent and
PostCollectionRemoveEvent to include the collection persister or the collection
role then we can do more stuff when the collection inside the event is null (I
do not know if someone asked and created a JIRA for Hibernate to add that in
the event nor if they are going to do that change in the near future)
As a work around I would suggest to not replace the whole collection when the
collection was not loaded from the database if this is possible.
I have to think about this problem and if we can go around those obstacles that
I've mentioned without any Hibernate changes and to not miss events.
For now I will leave this issue open.
Original comment by kchobant...@gmail.com
on 8 Dec 2011 at 5:20
I have created a new Hibernate JIRA for accessing the collection persister even
when the collection was not loaded/new/or null
https://hibernate.onjira.com/browse/HHH-6882
Original comment by kchobant...@gmail.com
on 8 Dec 2011 at 6:03
Original issue reported on code.google.com by
Mr.Sony....@gmail.com
on 6 Dec 2011 at 9:38