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.  [ 1 post ] 
Author Message
 Post subject: query a class with a composite id
PostPosted: Fri Jan 21, 2005 1:26 pm 
Newbie

Joined: Thu Oct 07, 2004 9:15 am
Posts: 5
Hello,


I have a class called ClientAccount that has two primary keys (clientId and instanceId). I have created another class called ClientAccountId to manage the two primary keys (in this class i have extended serializable and implemented hashCode and equals methods).

Now I want to query the database and ask for all the entries where instaceId=3 and clientId contains 'DER'.

Is this the query?
in mapping file:
advancedQuery= "from ClientAccount g where g.ClientAccountId = :ClientAccountId";

ClientAccountId account = new ClientAccountId();
account.setClientId("%DER%");
account.setFeedInstanceId("3");
Query clientNames = session.getNamedQuery(advanceQuery);
clientNames.setEntity("ClientAccountId", account);
List results = clientNames.list();

it gives errors, anyone can help me to retrieve this list ?? do i have to implement serializable and include the two methods in the class ClientAccount as well?

Thanks


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

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.