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

Sort Order: Ascending order - Click to sort in descending order
Alexander Ley added a comment - 19/Apr/13 05:23 PM
Test case and trace

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?

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 added a comment - 22/Apr/13 01:04 PM
SVN trunk passes on that