Home » Eclipse Projects » EclipseLink » remove without removing
remove without removing [message #769068] |
Wed, 21 December 2011 10:38 |
Tom Eugelink Messages: 817 Registered: July 2009 |
Senior Member |
|
|
Maybe someone can explain how this can occur: I execute a EM.remove(e) on an entity (ProductionorderDeliveryline 1019) by executing:
em.remove( em.merge(e) );
In the log I see:
2011-12-21 09:24:23,736 DEBUG nl.knowledgeplaza.util.jpa.EntityManagerExtender.executeDelayedRemoveActions(EntityManagerExtender.java:239) #f2c499 Removing entity: nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
[EL Finest]: 2011-12-21 09:24:23.736--UnitOfWork(499193)--Thread(Thread[AWT-EventQueue-0,6,main])--Merge clone with references nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
[EL Finest]: 2011-12-21 09:24:23.736--UnitOfWork(499193)--Thread(Thread[AWT-EventQueue-0,6,main])--The remove operation has been performed on: nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
The next thing in the log involving this entity is:
[EL Finest]: 2011-12-21 09:24:23.783--UnitOfWork(499193)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query UpdateObjectQuery(nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019)
[EL Fine]: 2011-12-21 09:24:23.783--ClientSession(27562046)--Connection(21514890)--Thread(Thread[AWT-EventQueue-0,6,main])--UPDATE productionorder_deliveryline SET dwhmodified = ?, productionorder_deliverynr = ?, lazylock = ? WHERE ((productionorder_deliverylinenr = ?) AND (lazylock = ?))
bind => [2011-12-21 09:24:19.876, null, 2, 1019, 1]
Update? Que?
Naturally this fails on productionorder_deliverynr not being allowed to have a null value.
Where, why and how did a delete become an update?
Tom
|
|
|
Re: remove without removing [message #769133 is a reply to message #769068] |
Wed, 21 December 2011 13:02 |
Tom Eugelink Messages: 817 Registered: July 2009 |
Senior Member |
|
|
>
> Where, why and how did a delete become an update?
This only happens if I not only delete this one entity, but immediately also add a replacement one. If the 1019 only is deleted, this is in the log:
2011-12-21 13:40:44,696 DEBUG nl.knowledgeplaza.util.jpa.EntityManagerExtender.executeDelayedRemoveActions(EntityManagerExtender.java:239) #1e27dce Removing entity: nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
[EL Finest]: 2011-12-21 13:40:44.696--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Merge clone with references nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
[EL Finest]: 2011-12-21 13:40:44.696--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query ReadObjectQuery(referenceClass=ProductionorderDeliveryline )
[EL Fine]: 2011-12-21 13:40:44.696--ClientSession(25309840)--Connection(21514890)--Thread(Thread[AWT-EventQueue-0,6,main])--SELECT productionorder_deliverylinenr, dwhmodified, batchtransferlinenr, comment, lazylock, dwhby, amount, productionorder_outputlinenr, productionorder_deliverynr FROM productionorder_deliveryline WHERE (productionorder_deliverylinenr = ?)
bind => [1019]
[EL Finest]: 2011-12-21 13:40:44.696--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query ReadObjectQuery(name="iProductionorderOutputline" referenceClass=ProductionorderOutputline )
[EL Finest]: 2011-12-21 13:40:44.696--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query ReadObjectQuery(name="iProductionorderDelivery" referenceClass=ProductionorderDelivery )
[EL Finest]: 2011-12-21 13:40:44.696--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--The remove operation has been performed on: nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019
....
[EL Finest]: 2011-12-21 13:40:44.758--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query UpdateObjectQuery(nl.reinders.bm.ProductionorderDeliveryline@10e47&ProductionorderDeliverylinenr=1019)
[EL Fine]: 2011-12-21 13:40:44.758--ClientSession(25309840)--Connection(21514890)--Thread(Thread[AWT-EventQueue-0,6,main])--UPDATE productionorder_deliveryline SET dwhmodified = ?, productionorder_deliverynr = ?, lazylock = ? WHERE ((productionorder_deliverylinenr = ?) AND (lazylock = ?))
bind => [2011-12-21 13:40:41.87, null, 2, 1019, 1]
[EL Finest]: 2011-12-21 13:40:44.758--UnitOfWork(2846280)--Thread(Thread[AWT-EventQueue-0,6,main])--Execute query DeleteObjectQuery(nl.reinders.bm.ProductionorderDeliveryline@10e48&ProductionorderDeliverylinenr=1019)
[EL Fine]: 2011-12-21 13:40:44.758--ClientSession(25309840)--Connection(21514890)--Thread(Thread[AWT-EventQueue-0,6,main])--DELETE FROM productionorder_deliveryline WHERE ((productionorder_deliverylinenr = ?) AND (lazylock = ?))
bind => [1019, 2]
The update statement also happens in this case but it is followed by a delete. Aside from that obvious difference, there is the additional select caused by the merge. Could this be cause by cascading update...
The entity class hierarchy is as follows:
PO ---1:N---> POOL <---N:1---
\ \
---1:N---> POD ---1:N---> PODL
PODL is ProductionOrderDeliveryLine.
On delete, the PODL and PO are cut free from the POOL & PO and removed. This works.
On add, a new POD is created, a new PODL is added to its collection, the PODL gets references to a POOL, and finally the POD is added to the PO.
Could the cascade update that is active on the collections turn a delete into an update?
ProductionOrderDeliveryLine:
@ManyToOne(fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.ProductionorderDelivery.class, cascade = {CascadeType.REFRESH} ) @JoinColumn(name="productionorder_deliverynr")
volatile protected nl.reinders.bm.ProductionorderDelivery iProductionorderDelivery;
ProductionOrderDelivery:
@OneToMany(mappedBy = "iProductionorderDelivery", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.ProductionorderDeliveryline.class, cascade = {CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.MERGE} )
volatile protected java.util.List<nl.reinders.bm.ProductionorderDeliveryline> iProductionorderDeliverylinesWhereIAmProductionorderDelivery = new java.util.ArrayList<nl.reinders.bm.ProductionorderDeliveryline>();
|
|
| |
Goto Forum:
Current Time: Thu Apr 18 09:12:24 GMT 2024
Powered by FUDForum. Page generated in 0.01752 seconds
|