-->
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: Question on HQL
PostPosted: Wed Dec 13, 2006 1:35 pm 
Newbie

Joined: Tue Dec 12, 2006 3:36 pm
Posts: 2
Location: nyc
Hi,

How can I convert the following query into HQL?

select * from m_tran mt inner join m_process mp on mt.id = mp.id where mp.type = 'ABCD' and mp.status = 'EFGH';

Essentially all I'm looking for is a list of objects which represent m_tran table based on the above criteria.

Also, can we use the Criteria* classes for this kind of situation?

Thanks,
Naylak


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 2:35 pm 
Newbie

Joined: Mon Dec 04, 2006 5:01 pm
Posts: 5
Well, what is an object? If I go with the supposition that n_tran is an object(lets call the object Tran) and m_process is another object(Process), which Tran holds a collection of, you might do something like this:

select Tran from Tran where Tran.Process.type = "ABCD" and Tran.Process.status = "EFGH"

That would return you a list of Tran objects matching your criteria. You could optimize with joins but Hibernate should be able to get what you have everything appropriately mapped together.

I think this would work fine using a Criteria as well, but I'm not sure of the exact syntax since I'm not sure exactly what you were wanting.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 2:57 pm 
Newbie

Joined: Tue Dec 12, 2006 3:36 pm
Posts: 2
Location: nyc
I was probably not clear in explaining the problem earlier.

m_tran is mapped to an Object MTran
m_process is mapped to another Object MProcess

They are two independent sibling tables which are mapped to a parent table via the id column. So, they don't have any direct relationship between themselves.

So, now I want to obtain all the rows from m_tran table which are having the same id as on m_process and are also satisfying the other two conditions. The obtained rows should probably be the MTran objects.

Let me know if that's clear.

Thanks,
Naylak


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.