-->
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.  [ 4 posts ] 
Author Message
 Post subject: select distinct exception
PostPosted: Mon Dec 08, 2003 10:37 pm 
Newbie

Joined: Fri Nov 28, 2003 9:08 am
Posts: 19
Location: Brasil
I had a query like this:

"select distinct client " +
"from Client as client " +
"inner join client.orders as orders " +
"order by client.name ";

Everything was fine, but I had to add a TEXT column to my Client table (OR mapping and accessors methods were added too).
And now I get a exception:

java.sql.SQLException: The text, ntext, or image data type cannot be selected as DISTINCT.

That


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 10:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this isn't clean at all but you can retrieve all properties of client except the TEXT one and build a client snapshot from it (this object won't be managed by Hibernate however).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 10:47 pm 
Newbie

Joined: Fri Nov 28, 2003 9:08 am
Posts: 19
Location: Brasil
What I did was:

"select client from Client client " +
"where client.id in ( " +
"select c.id " +
"from Client as c " +
"inner join c.orders as order " +
"group by c.id ) ";

So I still have hibernate managing all the objects generated by the query result.

What do you think about the solution?

Tks
Felipe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 10:55 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If your DB CPU can handle it, that's a much better solution.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.