Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unmanaged references

Although not generally a good idea, JPA does allow you to persist an object
with a reference to a non-managed existing object.  Is the object existing? 
What error do you get?

In general if you use merge() instead of persist() it should ensure the
correct managed object is referenced.  You could also manually lookup the
correct managed object to be referenced.

You could try the property "eclipselink.validate-existence", it may change
the behavior.



mgsoft wrote:
> 
> Hi,
> 
> we are just in transition from Hibernate to EclipseLink. While running the
> first tests we saw a difference between Hibernate and EclipseLink:
> 
> If I want to persist or update an entity that references an unmanaged
> object I get an error message that tells me that persisting the referenced
> unmanaged entity failed. Of course I don't want to cascade e.g. the
> persist of the entity reference that even hasn't an apporpriate annotation
> (Cascade.ALL or Cascade.Persist).
> In Hibernate it works without a problem. Do I have to attach (e.g by using
> find) the reference always before persisting an entity or is there a
> global setting to change this behaviour?
> 
> Thanks in advance!
> 
> 
> 


-----
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 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Unmanaged-references-tp31039202p31050690.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top