|
|
Re: java.lang.NullPointerException: when OrderedListContainerPolicy.updateChangeRecordForSelfMerge(. [message #1729462 is a reply to message #1729295] |
Thu, 14 April 2016 10:16 |
Juan Llado Messages: 3 Registered: April 2016 |
Junior Member |
|
|
Finally, I've reproduced the error.
It happens when I merge an entity which is into a OneToMany attribute of other entity. For example, I have a Trip (fetched from database) that it has a travellers attribute (a List<Traveller> with @OneToMany(cascade = CascadeType.ALL). So, if I execute the following:
Trip trip = entityManager.find(Trip.class, "123455");
Traveller traveller = trip.getTravellers().get(0);
traveller.setName("WTF!");
entityManager.merge(traveller);
traveller.setId("WTF-1");
entityManager.merge(trip);
Then I get the exception:
Caused by: java.lang.NullPointerException: null [918/1871]
at org.eclipse.persistence.internal.queries.OrderedListContainerPolicy.updateChangeRecordForSelfMerge(OrderedListContainerPolicy.java:712) ~[eclipselink.jar:2.6.2.v20151217-774c696]
Probably change the id of a persisted entity, it's not a good idea. But I think EclipseLink has to take control of the situation. Better than letting throw a NullPointerException. I really prefer a IllegalStateException with a proper message.
Maybe I can report it as a bug.
Thanks!
[Updated on: Thu, 14 April 2016 10:17] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03651 seconds