Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] NamedNativeQuery, SqlResultSetMapping and left outer join

Could you include the code and SQL for your query, and your object model.

I assume you are trying to select objects from the outer joined data, you
could try just selecting the data, then would not have id issues.

Their is an API of EclipseLink ObjectBuildingQuery
setShouldBuildNullForNullPk() that you could call, that would bypass this
error.  You could try setting this on your query.  Perhaps it should default
to true for result-set queries, you may want to log a bug for this.

((ObjectBuildingQuery)((JpaQuery)query).getDatabaseQuery()).setShouldBuildNullForNullPk(true);



Andrew Wang-4 wrote:
> 
> Hi,
> I am using a NamedNativeQuery that uses an OUTER LEFT JOIN.  I am using
> SqlResultSetMapping to get the columns that I want (I don't need all the
> columns from the 6 tables).  The return list is an object array of the
> entities with what I was hoping to be populated with the properties that I
> need.
> 
> The exception I am getting is:
> 
> Exception Description: The primary key read from the row [DatabaseRecord(
> ... )] during the execution of the query
> was detected to be null.  Primary keys must not contain null.
> 
> Which I am assuming that since the entities I am using have Id annotated
> properties, those properties can't be null (which makes sense).  But the
> nature of the OUTER LEFT JOIN is to retrieve those null values in table B
> for each entry in table A.
> 
> Should I be doing this another way ?
> 
> Thanks.
> 
> 


-----
---
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/NamedNativeQuery%2C-SqlResultSetMapping-and-left-outer-join-tp22681230p22701521.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top