Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Help expressing a grouped join
PostPosted: Tue May 29, 2012 5:35 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 208
Hi,

I need to produce a hql query that selects all the Posts in a group that have a reply and send the relevant posts to all the members that have participated in those discussions.

Can anyone do some suggestions about an efficient way to achieve this query? I was thinking of grouping the selecting result by user, but I'm not really sure about the best way to do this with a comment.user and a post.user.

My setup
Code:
public class Post{
        @ManyToOne
        Group group;

   @OneToMany
   Set<Comment> comments;
   
   @ManyToOne
   User user;
   
   @Column
   String comment;
}

Public class Comment{
   @ManyToOne
   Post post;
   
   @ManyToOne
   User user;
   
   @Column
   String comment;
}

public class Group{
        @OneToMany
        Set<GroupMember> members;
}

public class GroupMember{
        @ManyToOne
        Group group;

        @ManyToOne
        User user;
}


Marc


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.