|IndirectList executes a contains() check on add(). Why? [message #1730076]
||Thu, 21 April 2016 09:33
| Simon Eiersbrock
Registered: April 2010
the org.eclipse.persistence.indirection.IndirectList executes a contains() check inside the add method to prevent duplicate objects in the list. Why? Is this a feature that I do not understand? In my opinion this is a bug...
A java List can contain duplicates, only a java Set ensures no duplicates. So the IndirectList changes the behaviour of a List.
In my current project this causes an issue under this circumstances:
* Parent contains a List with ChildElements
* List is loaded LAZY
* ChildElement overrides equals()-Method to execute the equals-comparison only on its ID field (This simplifies a lot of things in my project so I do not want to change this)
* IDs of database objects are generated by the database (MSSQL with Identity column). A new instance of a child has the ID "null".
If I add more than one new child object to the list only the first object will get saved to the database (because the Indirect List assumes that the other child objects are duplicates of the first child)
Powered by FUDForum
. Page generated in 0.01963 seconds