Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] find after persist is not finding persisted value

Verify that your @PrePersist is being called on persist() and that the Id
value has been assigned after persist().

It is most likely that the event gets raised after persist() already did its
Id check, so the object is not put in the cache.  persist() should probably
take this into account, so please log a bug for this.

As a workaround, call flush(), or assign the Id before calling persist().



Ids are being assigned using @PrePersist methods. We are using UUIDs and
cannot rely on database sequences or jpa generated values.



James Sutherland wrote:
> 
> How is your Id assigned?  Is it using an IDENTITY GeneratedValue?  If so
> then it cannot be assigned an Id on persist(), only on flush, so doing a
> find() using its null Id will not find the object.
> 
> Either call flush(), or switch to using a TABLE or SEQUENCE
> GeneratedValue, it is much more efficient anyway.
> 
> 


-----
---
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/find-after-persist-is-not-finding-persisted-value-tp23041581p23059886.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top