-->
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: report queries & collections
PostPosted: Fri Sep 08, 2006 4:05 pm 
Newbie

Joined: Fri Sep 08, 2006 3:54 pm
Posts: 2
Hi all!

For example, I have classes
class Test {
int field1;
String field2;
List<Code> codes;
}

class Code {
int codeField1;
String codeField2;
}

I have to write a report query wich will retrieve field1, field2 and codeField1 from some of the codes associated with current Test object (with some specified condition on codeField2).
Which is the best and the most efficient way to do this? (even if I cannot do this in one query)

Thank you in advance.


Top
 Profile  
 
 Post subject: Re:
PostPosted: Sat Sep 09, 2006 7:40 am 
Newbie

Joined: Fri Sep 08, 2006 9:04 am
Posts: 3
Hi,

I think u can try something like :


select t.field1,t.field2,c.codeField1 from Test t,Code c where c.codeField2 = ?


this can be used by Query.createSQLQuery();


This will return the results in the form of a list of Object[].


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 7:46 am 
Newbie

Joined: Fri Sep 08, 2006 3:54 pm
Posts: 2
abhilashjena, I need only those codes which are referenced from the current Test object, and there aren't any joins or associations in your query..


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.