-->
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.  [ 2 posts ] 
Author Message
 Post subject: Un able to get HQL to work
PostPosted: Wed Oct 12, 2005 5:26 am 
Newbie

Joined: Wed Sep 14, 2005 4:57 am
Posts: 10
My sql code looks as follows

select e.id from entry e, groups_belong_to_group_member g where e.id=g.groups_belong_to_id and
group_entry='Yes' and
name like '%(Countries)%';

"groups_belong_to_group_member g" stores the value of e.id that is linked to a entry.
Therefore you could use the following code as well:


select e.id from entry e where
group_entry='Yes' and
name like '%(Countries)%' and e.id in (select e.id from entry e);

so "groups_belong_to_group_member g" is just a place to store the enry id on that specific entry.


I have tried to convert this to HQL but only get this far

sb.append("select entry from com.workpool.directory.Entry entry where ");
sb.append("entry.groupEntry=\"Yes\" and ");
sb.append("entry.name like '%(Countries)%'");

I still need to complete the rest of my code but can't use asub quiery as mysql cersion does not support it.

Is there some sort of join that can be done to get an object on a object

any help will be appreciated thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 10:16 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
you can use that first sql query you already have written. make it a named sql query in hibernate and it'll work just fine.

there are many good examples of sql named queries in the source test code that came with the hibernate download, if you just run a text search for sql-query on the hibernate/test folder.

also, session.createSqlQuery() works.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.