-->
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: Is Select DISTINCT possible?
PostPosted: Mon Sep 19, 2005 10:43 am 
Newbie

Joined: Fri May 13, 2005 11:14 am
Posts: 18
Is there any way I can just do a distinct select in HQL?

I would do this in SQL: select distinct name from table1.

Where table1 has an id (int identity field), name (string field), etc.

I tried using SqlSimpleSelectBuilder and that wants a index column.
I tried using HQL, but that wants a Persister class.

I tried this:
IQuery query = this.session.CreateSQLQuery("select distinct name from table1", "names", typeof(String));
files = query.List();

But, I get this error: ""No persisters for: System.String".

I don't want a persistable object, I just want a read-only list of strings to be honest.

Any help or direction would be great.

Thanks,
Jamie


Top
 Profile  
 
 Post subject: Figured it out
PostPosted: Mon Sep 19, 2005 11:12 am 
Newbie

Joined: Fri May 13, 2005 11:14 am
Posts: 18
This works:

string select = "select distinct rating.FileName from MoodysLoanRating rating";
IQuery query = this.session.CreateQuery(select);
files = query.List();

Just an FYI,
Jamie


Top
 Profile  
 
 Post subject: Select Distinct with where condition?
PostPosted: Thu Nov 10, 2005 1:16 pm 
Can you do a select distinct with a where condition?
I have not seen a single example of this?


something similar to

string select = "select distinct rating.FileName from MoodysLoanRating rating where rating.Score > 600";


Top
  
 
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.