Order of entity updates and inserts, concurrency... again.

Posts   
 
    
ivanc
User
Posts: 36
Joined: 29-Apr-2004
# Posted on: 31-Mar-2006 11:55:25   

Adapter scenario, concurrency is implemented using a timestamp column.

We have encountered a concurrency problem with entity updates and related table inserts if the related table insert triggers a trigger that updates the master table.

Example:

Order table : Order status table 1:n

When a new order is inserted (with a new status) recursive save inserts the entities in the correct order (order first, then the status).

If there is an update on the order table and a new order status insert then the recursive save (adapter.SaveEntity(order, true)) first inserts the status entity and then tries to update the order entity.

Because of the trigger on the order status table (that updates the order table) concurrency fails.

Is there a way to force the adapter to save master entities first (to update the order table before the order status insert)?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 31-Mar-2006 13:20:06   

No this isn't possible. Inserts are always done before updates to prevent FK violations caused by the updates if an insert hasn't taken place. The graph sorter first sorts the graph on dependencies, then places each entity into the right queue.

Frans Bouma | Lead developer LLBLGen Pro