-->
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: Query problem...
PostPosted: Mon Feb 27, 2006 12:01 pm 
Newbie

Joined: Wed Feb 01, 2006 9:44 am
Posts: 7
hi,

i have a table for my groups in the db (tbl_dbtool_group). this table have an id field which is primary key...therefor i have an Group.cs Class in my Code...

the following query does not work in my code:

Code:
string tmp = String.Format("select max({0}.Id) from {0}", "Group");
maxId = session.CreateQuery(tmp).List();


i became back the hole table data...what is wrong there??

thX
yesso


Top
 Profile  
 
 Post subject: Java, not .net
PostPosted: Mon Feb 27, 2006 4:00 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
I tried a similar example in Java and noticed I had to alias the source class. So instead of what you have:

"select max(Group.Id) from Group"

You'd need:

"select max(g.Id) from Group g"

And I suspect you should also be using UniqueResult() instead of List().


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 8:23 am 
Newbie

Joined: Wed Feb 01, 2006 9:44 am
Posts: 7
thank u very much;)

i have read again the docu and saw that the select needs the alias...

thx
yesso


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.