So how do I get it to update correctly?
If I remove an item from the top of a list (and shuffle the other entries up - I don't want gaps), then it gets a duplicate key error.
Code:
07:44:33,656 INFO [STDOUT] Hibernate: update Menu_subMenus set subMenus_uuid=? where Menu_uuid=? and submenuIndex=?
07:44:33,671 WARN [JDBCExceptionReporter] SQL Error: 1062, SQLState: 23000
07:44:33,671 ERROR [JDBCExceptionReporter] Duplicate key or integrity constraint violation message from server: "Duplicate entry '149' for key 1"
07:44:33,671 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
I'm updating using
Code:
<node className="com.fcl.greenfield.entity.Menu" description="App. Data" uuid="74">
<node className="com.fcl.greenfield.entity.Menu" description="AppComponent" uuid="149"/>
<node className="com.fcl.greenfield.entity.Menu" description="AppTaxNoValidation" uuid="150"/>
</node>
Now, there
was an entry at the top of the list, with a uuid of 148 which I removed. I moved the two subsequent entries up by one position. Then I asked the EntityManager to persist the top level Menu object.
Now, 149 is at position 0 in the list, and 150 is at position 1.
It should
just delete the link table entry from parent Menu 74 to subMenu 148, and then change the index column of subsequent entries. It's not, it's
changing entry 0 in the link table to point to subMenu 149, and that causes the error, because entry 1 already points to it.
What it needs to do is go down the 74->* entries in the link table, just changing every linked-to uuid to match what's in the List. Then delete any left over at the end. That's it. Do I have to do it manually?
How do I get it to update the list correctly? Or do I have to set deleted entries in ordered
Lists 0 in the List to null, and put up with gaps in retrieved
Lists? If people update a lot there could be enormous gaps! That solution is not good enough!