persistence@glassfish.java.net

createNamedQuery error

From: dhalsim <rr4132_at_hotmail.com>
Date: Wed, 25 Feb 2009 20:17:55 -0800 (PST)

Hi,
I created the following NamedQuery in my entity class:

@NamedQuery
(name = LocationGroupEntity.QUERY_FIND_CHILD_LOCATION_BY_PARENT_LOCATION,
query = "select l from LocationGroupEntity l where l.parentLocationId =
:parentLocationId and l.isActive = true"
)

Here's how I defined the field in the class:

@Id
@Column(name = "parent_loc_cd")
private long parentLocationId;

When I executed the code that will execute the query and get the result, I
encountered the following error:

Hibernate: select locationgr0_.childLocationId as childLoc1_9_,
locationgr0_.parentLocationId as parentLo2_9_, locationgr0_.active_ind as
active3_9_ from LOCATION_GROUP locationgr0_ where
locationgr0_.parentLocationId=? and locationgr0_.active_ind=1
0 [btpool3-1] WARN org.hibernate.util.JDBCExceptionReporter - SQL
Error: 904, SQLState: 42000
15 [btpool3-1] ERROR org.hibernate.util.JDBCExceptionReporter -
ORA-00904: "LOCATIONGR0_"."PARENTLOCATIONID": invalid identifier

Here's the snippet of the code that was executed:

final Query query =
entityManager.createNamedQuery(LocationGroupEntity.QUERY_FIND_CHILD_LOCATION_BY_PARENT_LOCATION);

query.setParameter("parentLocationId",
SimpleMID.getCanonicalValue(criteria.getLocationMID()));

final List<LocationGroupEntity> LocationGroupEntities =
query.getResultList(); // This is where the exception was thrown.

I think the syntax of the query is correct, so I am not sure why it doesn't
recognize the parentLocationId. I attached the full class in case somebody
want to take a look at it.
Any suggestions on what I might miss will be appreciated.

Thanks,

Dhalsim http://www.nabble.com/file/p22217390/LocationGroupEntity.java
LocationGroupEntity.java
http://www.nabble.com/file/p22217390/LocationGroupKey.java
LocationGroupKey.java
-- 
View this message in context: http://www.nabble.com/createNamedQuery-error-tp22217390p22217390.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.