Data loss within postCalculateUnitOfWorkChangeSet() event

View: New views
2 Messages — Rating Filter:   Alert me  

Data loss within postCalculateUnitOfWorkChangeSet() event

by patric-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone,

I am using a SessionEventListener to persist new objects during the  
postCalculateUnitOfWorkChangeSet() event.

These objects won't get persisted in the next writeChanges() call  
(e.g. flush/transaction commit) by the UnitOfWork. The UnitOfWork  
doesn't recognize the new objects as new, isObjectNew(object); returns  
false.

As a consequence, the UnitOfWork does an update instead of an insert  
(which of course fails because the record doesn't exist, but without  
an exception) - the object is lost.

Are there any workarounds for this bug?

Best regards,
Patric






_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Data loss within postCalculateUnitOfWorkChangeSet() event

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The event postCalculateUnitOfWorkChangeSet is raised after (post) computing what will be written, so it is too late to write anything else, you would need to use the preCalculateUnitOfWorkChangeSet for this.

How are you persisting your object in postCalculateUnitOfWorkChangeSet?  You might need to register them, or add their change set to the UnitOfWorkChangeSet.

patric-5 wrote:
Hello everyone,

I am using a SessionEventListener to persist new objects during the  
postCalculateUnitOfWorkChangeSet() event.

These objects won't get persisted in the next writeChanges() call  
(e.g. flush/transaction commit) by the UnitOfWork. The UnitOfWork  
doesn't recognize the new objects as new, isObjectNew(object); returns  
false.

As a consequence, the UnitOfWork does an update instead of an insert  
(which of course fails because the record doesn't exist, but without  
an exception) - the object is lost.

Are there any workarounds for this bug?

Best regards,
Patric