Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Data updated during aboutToInsert isnt getting persisted

At the point of the aboutToInsert event the row to insert has already been
built.  To effect the insert, you need to modify the row
(event.getRecord()).  The preInsert event is raised before the row is built,
so you could change the object in preInsert.



khaskett wrote:
> 
> Just an update to this post..
> This is the code that is running just prior to the insert.
> 
> public void aboutToInsert(DescriptorEvent event) {
>         CpBuildingInterestLink bil = (CpBuildingInterestLink)
> event.getObject();
>         if (bil.getInterestLinkId() == null) {
>             bil.setInterestLinkId(new
> CpInterestLinkId(getCpInterestType().getInterestTypeId(),
> cpBuilding.getBuildingId()));
>         }
>     }
> 
> I notice that both the entity that represents "this" object, and what I
> get from event.getObject are one in the same.  Initially I had thought
> they were different.
> 
> 
> khaskett wrote:
>> 
>> I added the DescriptorEventListener to one of my Entities, and then in
>> the aboutToInsert method, I added some code to update the EmbedddId field
>> entry to the value of one the parent entities autogenerated id's.  When I
>> step through the code it stops just prior to that entity getting
>> inserted, as I can see the parent entity getting inserted, and I can see
>> the code execute in the aboutToInsert adding the appropriate values, but
>> when it actually runs the insert it still has null as the value in the
>> fields I had updated.
>> 
>> Any ideas on why this is happening?
>> 
>> 
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Data-updated-during-aboutToInsert-isnt-getting-persisted-tp25928146p25974402.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top