Issue Details (XML | Word | Printable)

Key: NUCCORE-1031
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Alexander Ley
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Core

NoSuchElementException after Collection.add/remove with javax.jdo.option.Optimistic=true

Created: 19/Apr/13 05:21 PM   Updated: 15/May/13 09:31 AM   Resolved: 22/Apr/13 01:04 PM
Component/s: None
Affects Version/s: 3.2.1
Fix Version/s: 3.2.3

File Attachments: 1. Text File NUCRDBMS-668-patch.txt (1 kB)
2. Zip Archive (3 kB)
3. Zip Archive (9 kB)

Environment: JDO, Oracle 11.2, Windows 7

Datastore: Oracle

 Description  « Hide
I get the following exception after removing and re-adding of the same member to a collection (master.children.remove(child); master.children.add(child)):

at java.util.AbstractList$
at org.datanucleus.ExecutionContextImpl.flushSCOOperationsForBackingStore(
at org.datanucleus.state.JDOStateManager.flush(
at org.datanucleus.FlushOrdered.execute(
at org.datanucleus.ExecutionContextImpl.flushInternal(
at org.datanucleus.ExecutionContextImpl.flush(
at org.datanucleus.ExecutionContextImpl.preCommit(
at org.datanucleus.ExecutionContextImpl.transactionPreCommit(
at org.datanucleus.TransactionImpl.internalPreCommit(
at org.datanucleus.TransactionImpl.commit(
at org.datanucleus.api.jdo.JDOTransaction.commit(
at org.datanucleus.test.MainMasterDetail.main(

This happens in optimistic locking mode only.

Alexander Ley added a comment - 19/Apr/13 05:23 PM
Test case and trace

Alexander Ley made changes - 19/Apr/13 05:23 PM
Field Original Value New Value
Attachment [ 11941 ]
Attachment [ 11942 ]
Alexander Ley added a comment - 22/Apr/13 10:45 AM - edited
Patch to solve the NoSuchElementException.
But there is an other problem: Ignoring remove() followed by an add() is wrong for sorted collections.
If I remove the first element and than add this element again, it should be moved to the end of the collection.
What is right way to change the order of the elements in a RDBMS List?

Alexander Ley made changes - 22/Apr/13 10:45 AM
Attachment NUCRDBMS-668-patch.txt [ 11943 ]
Andy Jefferson added a comment - 22/Apr/13 12:45 PM - edited
The logic in that method was attempting to optimise out certain user input errors. remove() is always going to remove the first incidence of an element whereas add is the last one, hence needs changing to not apply to Lists, correct

Andy Jefferson made changes - 22/Apr/13 01:00 PM
Project DataNucleus Store RDBMS [ 10144 ] DataNucleus Core [ 10143 ]
Affects Version/s 3.2.1 [ 11914 ]
Affects Version/s 3.2.1 [ 11918 ]
Andy Jefferson added a comment - 22/Apr/13 01:04 PM
SVN trunk passes on that

Andy Jefferson made changes - 22/Apr/13 01:04 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.2.3 [ 11924 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 15/May/13 09:31 AM
Status Resolved [ 5 ] Closed [ 6 ]