Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] SQL emitted by EclipseLink is searchingforan object with a null primary key

Morning James,

The Visit class bears the @OptimisticLocking(cascade=true) annotation,
and we get the same statement executed if the cascade attribute is
instead set to false. Also, the ManyToOne back reference from Service to
Visit has been set.

I have created EclipseLink defect 264406 per your request.



-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of James
Sent: Tuesday, February 10, 2009 5:33 AM
To: eclipselink-users@xxxxxxxxxxx
Subject: RE: [eclipselink-users] SQL emitted by EclipseLink is
searchingforan object with a null primary key

>From the stack the query is being executed by the cascaded locking
policy, I
assume you are using cascaded locking on the new Visit which is
owned by the new Service?  Did you set the ManyToOne back reference, as
seems to be null?

It seems odd that it would be trying to query for the parent, especially
a new object, so might be good to log a bug for this, as the code does
seem correct.  Include this post in the bug.

RE: SQL emitted by EclipseLink is searching foran object with a null
key Click to flag this post

by Gschwind, Doug Feb 09, 2009; 01:20pm :: Rate this Message: (use
to moderate[?])

Reply | Reply to Author | Delete | Show Only this Message
Hi James,

Sure, let me give you a little more context. The relevant domain model
classes for this use case are : Chart, Visit, and Service (and
subclasses of Service). There is a OneToMany from Chart to Visit, a
ManyToOne from Visit to Chart, a OneToMany from Visit to Service, and a
ManyToOne from Service to Visit, that are all JPA mapped.

In this use case, we are simply trying to create a new Service instance
and make it persistent, stitching up all of the appropriate
relationships prior to attempting to persist. Also, the Chart instance
is already persistent. I believe we are also going to persist a Visit as
part of creating a new Service in my test case.

Attached you will find the standard output stream from OC4J, with the
EclipseLink logging level set to FINEST. Additionally, I used the
StackDumpingPerformanceProfiler (a specialization of EclipseLink's
PerformanceProfiler provided to us by Randy Stafford) to help see the
stack trace that caused the query to be executed.

On line 7390 in the output you will see the odd select statement of the
form, SELECT * from SERVICE where SVCID = null. If you then look on line
7399, you can trace the cause of that SQL statement to where in our code
we call EntityManager.flush().

Let me know if I can provide you some more info.



--- James
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

eclipselink-users mailing list

The contents of this electronic mail message and any attachments are confidential, possibly privileged and intended
for the addressee(s) only. Only the addressee(s) may read, disseminate, retain or otherwise use this message. If
received in error, please immediately inform the sender and then delete this message without disclosing its contents
to anyone.

Back to the top