Hi Chris,
The column name in the database is called parent_loc_cd.
I am using the @Column annotation to denote that the column name and the
entity field are different.
@Id
@Column(name = "parent_loc_cd")
private long parentLocationId;
Isn't this a correct way to use @column?
Thanks,
-Richard
Christopher Delahunt wrote:
>
> I don't know or use Hibernate, so you should probably try their forums
> to get hibernate specific help, but nothing seems to be wrong with the
> annotations themselves. Do you have a PARENTLOCATIONID column in the
> database?
>
> Regards,
> Chris
>
> dhalsim wrote:
>> 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-tp22217390p22226286.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.