-->
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.  [ 2 posts ] 
Author Message
 Post subject: distinct selection
PostPosted: Fri Feb 20, 2009 2:26 am 
Newbie

Joined: Mon Jul 21, 2008 5:40 am
Posts: 16
Hi,

I have two tables and I'd like to query the last 20 comments, this works:

session.createQuery("from Comments order by cm_date desc").setMaxResults(20).list()

I'd like to make sure that there is no Comments from the same User in the last 20, any idea?

Thanks,

Angelo


public class Comments
{
private Long id;
private User user;
private Timestamp cm_date;
}

public class User {
private Long id;
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2009 7:02 am 
Beginner
Beginner

Joined: Thu Feb 19, 2009 5:48 am
Posts: 37
Location: Glasgow, Scotland
Again, I'm just new myself but I'm guessing there's something like...

Code:
session.createQuery("select * distinct users from Comments order by cm_date desc").setMaxResults(20).list()


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.