-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query on a composite element
PostPosted: Wed May 17, 2006 10:26 am 
Newbie

Joined: Wed May 17, 2006 10:02 am
Posts: 4
I've a little problem with a SELECT query on a composite field ( is the table primary key too). The field is like the following on hibernate mapping file

......
<composite-id name="Id" class="MyClass">
<key-property
name="Field1"
column="COLUMN1"
type="string"
/>
<key-property
name="Field2"
column="COLUMN2"
type="string"
/>
</composite-id>
.....

The query that i'm using is

SELECT a FROM MyObject a WHERE a.Field1 = :username and a.Field2 = :pwd

and the hibernate exception is

could not resolve property: Field2 of:
MyClass [SELECT a FROM MyClass a WHERE a.Field1 = :username and a.Field2 = :pwd]


I tried to execute query with other fields ( single fields ) and i don't have problems..... So how can i do this ?

Thanx


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 10:46 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Try adding the composite name to the path, eg:-

Code:
SELECT a FROM MyObject a WHERE a.Id.Field1 = :username and a.Id.Field2 = :pwd


Hope that helps.
Cheers,
rich.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 17, 2006 11:28 am 
Newbie

Joined: Wed May 17, 2006 10:02 am
Posts: 4
Thanx a lot !! It works....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.