-->
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: HQL
PostPosted: Sun Jan 20, 2008 2:50 pm 
Newbie

Joined: Sun Jan 20, 2008 1:43 pm
Posts: 1
Hi. I have 2 models

Code:
public class User extends BaseObject{
    private Long id;
    private String name;
    private String location;
    private String sex;
    private String birthdate;
    private List friends;
.......
public class Friend extends BaseObject{
    private Long id;
    private User fk;
    private String friend;
.......



if I show 1 User and all of his friends, a query will be such:
Code:
hql = "From User u " +
         "left outer join fetch u.friends f where u.id = ?";


Result:
Code:
John / m / London / Bill
                      Bob
                      Ann


And I need to show out all of friends, and friends of this User select in multiple-selection. Example:

Code:
John / m/ London / <Bill>
                      <Bob>
                      <Ann>
                      Andy
                      David


How correct to write a query?


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.