|DoesExistQuery in nosql [message #1018856]
||Thu, 14 March 2013 15:17
| Johan Vos
Registered: March 2013
I am working with Eclipselink 2.5.0-SNAPSHOT with nosql support (trunk|
code from git).
Arun's simple example
at blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql is
working, but my own code using @ManyToOne was not working. I dove in
the eclipselink source code, and it seems that persisting an object
with a @ManyToOne annotation to another object only works if the
referred object has been made persistent in the same JPA session. In
that case, the referred object is added to the clonemap in
org/eclipse/persistence/internal/sessions/UnitOfWorkImpl, and the
clonemap is checked for all object fields in an object before that one
is made persistent. If one of the objects is not in the clonemap
(UnitOfWorkImpl.isObjectRegistered() returns false), a DoesExistQuery
will be executed, and this query is not yet supported in
In my example, a user is registered and stored in a mongo db. That
works fine. Later (after stopping/starting the server), the user has
to login again, and the User object is successfully retrieved from the
mongo db (using a NamedQuery, works fine). Next, a Content object is
created with the given User on the .author field. Storing that Content
object fails due to "DoesExistQuery is not supported".
Is there a workaround for this, or do I wait till DoesExistQuery is implemented?
|Re: DoesExistQuery in nosql [message #1020599 is a reply to message #1018856]
||Mon, 18 March 2013 14:41
| James Sutherland
Registered: July 2009
Location: Ottawa, Canada
Sounds like you are mixing managed and detached objects? You should not do this in JPA in general, regardless of NoSQL.|
You should first persist the Context object, or if it is existing, read it from the current persistence context.
Is your relationship cascade persist?
You could log a bug that the DoesExistQuery is not auto generated, this should be possible for most NoSQL platforms. You could also define your own DoesExistQuery using a DescriptorCustomizer.
James : Wiki : Book : Blog : Twitter
Powered by FUDForum
. Page generated in 0.01953 seconds