DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to.
DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued

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)):

java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
at org.datanucleus.store.types.queued.SCOOperationQueue.performAll(SCOOperationQueue.java:109)
at org.datanucleus.ExecutionContextImpl.flushSCOOperationsForBackingStore(ExecutionContextImpl.java:4072)
at org.datanucleus.store.rdbms.mapping.java.CollectionMapping.postUpdate(CollectionMapping.java:195)
at org.datanucleus.store.rdbms.mapping.oracle.OracleCollectionMapping.postUpdate(OracleCollectionMapping.java:95)
at org.datanucleus.store.rdbms.request.UpdateRequest.execute(UpdateRequest.java:419)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateTable(RDBMSPersistenceHandler.java:417)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateObject(RDBMSPersistenceHandler.java:390)
at org.datanucleus.state.JDOStateManager.flush(JDOStateManager.java:5012)
at org.datanucleus.FlushOrdered.execute(FlushOrdered.java:106)
at org.datanucleus.ExecutionContextImpl.flushInternal(ExecutionContextImpl.java:4019)
at org.datanucleus.ExecutionContextImpl.flush(ExecutionContextImpl.java:3970)
at org.datanucleus.ExecutionContextImpl.preCommit(ExecutionContextImpl.java:4122)
at org.datanucleus.ExecutionContextImpl.transactionPreCommit(ExecutionContextImpl.java:615)
at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:375)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:264)
at org.datanucleus.api.jdo.JDOTransaction.commit(JDOTransaction.java:98)
at org.datanucleus.test.MainMasterDetail.main(MainMasterDetail.java:67)

This happens in optimistic locking mode only.

Description

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)):
java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
at org.datanucleus.store.types.queued.SCOOperationQueue.performAll(SCOOperationQueue.java:109)
at org.datanucleus.ExecutionContextImpl.flushSCOOperationsForBackingStore(ExecutionContextImpl.java:4072)
at org.datanucleus.store.rdbms.mapping.java.CollectionMapping.postUpdate(CollectionMapping.java:195)
at org.datanucleus.store.rdbms.mapping.oracle.OracleCollectionMapping.postUpdate(OracleCollectionMapping.java:95)
at org.datanucleus.store.rdbms.request.UpdateRequest.execute(UpdateRequest.java:419)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateTable(RDBMSPersistenceHandler.java:417)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateObject(RDBMSPersistenceHandler.java:390)
at org.datanucleus.state.JDOStateManager.flush(JDOStateManager.java:5012)
at org.datanucleus.FlushOrdered.execute(FlushOrdered.java:106)
at org.datanucleus.ExecutionContextImpl.flushInternal(ExecutionContextImpl.java:4019)
at org.datanucleus.ExecutionContextImpl.flush(ExecutionContextImpl.java:3970)
at org.datanucleus.ExecutionContextImpl.preCommit(ExecutionContextImpl.java:4122)
at org.datanucleus.ExecutionContextImpl.transactionPreCommit(ExecutionContextImpl.java:615)
at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:375)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:264)
at org.datanucleus.api.jdo.JDOTransaction.commit(JDOTransaction.java:98)
at org.datanucleus.test.MainMasterDetail.main(MainMasterDetail.java:67)
This happens in optimistic locking mode only.

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 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?

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 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