-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: How to access composite-id elements from HQL
PostPosted: Thu Jan 12, 2006 8:16 am 
Newbie

Joined: Tue Jan 03, 2006 2:34 pm
Posts: 8
I got this exception :
org.hibernate.QueryException: could not resolve property: type_eko of: data.Releve

In java I got 2 classes : Releve.java and ReleveId.java ('ReleveID' represents the composite-id of 'Releve')

How should I do to access "Releve.ReleveId.type_eko" from my HQL query ??



Hibernate version:
Hibernate3

Mapping documents:

<class name="data.Releve" table="releve">
<composite-id name="id" class="data.ReleveId">
<key-property name="timestamp" type="timestamp">
<column name="timestamp" length="19" />
</key-property>
<key-property name="ekoId" type="integer">
<column name="eko_id" />
</key-property>
<key-property name="idCompteur" type="integer">
<column name="id_compteur" />
</key-property>
<key-property name="typeEko" type="integer">
<column name="type_eko" />
</key-property>
</composite-id>
<property name="aler
...


HQL Query:

releveList = (List) session.createCriteria(Releve.class)
.add( Expression.in( "type_eko" , new Integer[] { 0,1 }) )



Top
 Profile  
 
 Post subject: Re: How to access composite-id elements from HQL
PostPosted: Thu Jan 12, 2006 8:31 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
MrShadow wrote:
HQL Query:

releveList = (List) session.createCriteria(Releve.class)
.add( Expression.in( "type_eko" , new Integer[] { 0,1 }) )



How about

Code:
releveList = (List) session.createCriteria(Releve.class)
            .add( Expression.in( "id.type_eko" , new Integer[] { 0,1 }) )


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 8:33 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Sorry should be

Code:
releveList = (List) session.createCriteria(Releve.class)
            .add( Expression.in( "id.typeEko" , new Integer[] { 0,1 }) )


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 8:35 am 
Newbie

Joined: Tue Jan 03, 2006 2:34 pm
Posts: 8
I tried this too... but same result :

could not resolve property: id.type_eko of: Releve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 8:37 am 
Newbie

Joined: Tue Jan 03, 2006 2:34 pm
Posts: 8
Yes !! You'r right :

"id.typeEko" works fine !

Many many tx !!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.