Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » UnitOfWork events
UnitOfWork events [message #491099] Tue, 13 October 2009 09:15 Go to next message
Ana Oleski is currently offline Ana OleskiFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,

I'm trying to implement a validity-check on all new objects before the unit of work commits (we have "transient" objects with negative ids that should never be put into a relationship with persistent objects but sometime they are).

I thought I would be easy: register for the preCommitUnitOfWork event and examine every object in unitOfWork.getNewObjectsCloneToOriginal().

This approach turned out to have a problem: I only find the new objects that have been explicitely registered and not those that are persisted by reachability.

I looked some more and found the postCalculateUnitOfWorkChangeSet event, which seems to be a good place to do what I want. Only it doesn't. I still don't find all new objects.

I do find them after the commit (postCommitUnitOfWork event) but this is too late, since the database already contains junk.

Of course we can put a constraint in the database and we probaby will. But it still bugs me. What is the true eclipselink way Razz to do this?

Thanx,

Ana
Re: UnitOfWork events [message #491185 is a reply to message #491099] Tue, 13 October 2009 15:05 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The non-registered new objects are contained in unregisteredNewObjects (uow.getUnregisteredNewObjects()), you may be able to find them there. You can also trigger them to be discovered if you call uow.assignSequenceNumbers().

You want to try using the preInsert DescriptorEvent instead.


James : Wiki : Book : Blog : Twitter
Re: UnitOfWork events [message #491390 is a reply to message #491185] Wed, 14 October 2009 12:27 Go to previous message
Ana Oleski is currently offline Ana OleskiFriend
Messages: 22
Registered: July 2009
Junior Member
The preInsert DescriptorEvent is exactly what I've been looking for. Thank you!



Previous Topic:SQLResultSetMapping - aliases in NativeQuery not working
Next Topic:Mapping arrays
Goto Forum:
  


Current Time: Mon Dec 22 17:06:57 GMT 2014

Powered by FUDForum. Page generated in 0.01923 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software