-->
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: How to instance of a collection in 1-M hibernate mapping?
PostPosted: Thu Sep 24, 2009 12:31 pm 
Newbie

Joined: Fri Sep 18, 2009 1:50 pm
Posts: 6
Hi I have quiry on hibernate mapping in generating hql for the below scenario

I have a ClassA (TableA) which has 1-M mapping to ClassB(TableB)

In ClassA I have collection of ClassB (1-M mapping)

When I run the hql based on the search criteria on ClassA. It is working fine and I am getting list of ClassA, with each ClassA instance having collection of ClassB

select * from ClassA a where a.col1="A" and a.col2="B"

Now the issue is when I want to add seach condition for ClassB. How to get instance of ClassB to make a seach hql? expected results should be "list of ClassA with each CLassA instance having collection of ClassB"

I tries the below hql,
select * from ClassA a join ClassB b where a.col1="A" and b.col1="B"

But I am not getting expected results. Instead I am getting List of List. Where each list has ClassA and ClassB. Instead of collection in Class A, I am getting one List for reach record in ClassB

Some pls assist me on this.

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.