Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] getResultList causes QueryException Primary key is null

There are no field names in your row, this is causing the error.  This means
that your JDBC driver is not returning any column names in its
ResultSetMetaData, without the field names, EclipseLink has no way to map
the results.  What database and JDBC driver are you using?  It seems that it
does not support meta-data.



khaskett wrote:
> 
> Trying to execute a namedQuery using a result class.  I am getting a
> QueryException (EclipseLink-6044) - 
> The primary key read from the row [DatabaseRecord(
> 	 => 44
> 	 => /Account
> 	 => Action that selects /Account/Search or /Account/Details.
> 	 => U
> 	 => N
> 	 => 0)] 
> during the execution of the query was detected to be null.  Primary keys
> must not contain null.
> 
> From the looks of the error message all my fields are coming back
> correctly from the sql call.
> 
> Here is the entity result class I am trying to use.
> @NamedNativeQuery(
>         name = "findCpSecuredFeatureList",
>         query = "select distinct s.feature_id, s.feature_name,
> s.feature_desc, s.feature_type, s.license_check, rs.privilege_level "
>             + "from cp_secured s, cp_role_secured rs, cp_userrole ur "
>             + "where s.feature_id = rs.feature_id and
> ur.role_code=rs.role_code and ur.user_id=? "
>             + "order by rs.privilege_level desc, s.feature_name", 
>         resultClass = CpSecuredFeature.class
>         )
> @Entity
> public class CpSecuredFeature extends BaseDomain {
> 
>     private static final long serialVersionUID = -3727509833171729708L;
>     
>     @Id
>     @Column(name = "feature_id")
>     private Long featureId;
>     
>     @Column(name = "feature_name")
>     private String featureName;
>     
>     @Column(name = "feature_desc")
> 	private String featureDescription;
>     
>     @Column(name = "feature_type")
> 	private String featureType;
>     
>     @Column(name = "license_check")
> 	private boolean licenseRequired;
>     
>     @Column(name = "privilege_level")
> 	private int privilegeLevel;
> .....
> 
> Any ideas on why this is happening?
> 


-----
---
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/getResultList-causes-QueryException-Primary-key-is-null-tp20671004p20682072.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top