-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to make this: "SELECT userid,username, 'S' from use
PostPosted: Mon Dec 01, 2003 10:38 am 
Newbie

Joined: Mon Dec 01, 2003 10:31 am
Posts: 4
Hello,

I don't know how to do this query with hibernate:

select userid,username,'S' where userid in
(
select userid from usermap where usermap.userrole = 2
)
union
select userid,username,'N' where userid NOT in
(
select userid from usermap where usermap.userrole = 2
)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 11:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can't use constant in select so 'S' can't be returned by HQL

_________________
Emmanuel


Top
 Profile  
 
 Post subject: How to make this: "SELECT userid,username, 'S' from use
PostPosted: Mon Dec 01, 2003 11:33 am 
Newbie

Joined: Mon Dec 01, 2003 10:31 am
Posts: 4
Ok,

Now, is it impossible to do this query with hibernate? Is it possible with hibernate 2.1?

A lot of thanks,

Marcial


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 11:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate does not support unions. Use two queries.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 12:42 pm 
Newbie

Joined: Mon Dec 01, 2003 10:31 am
Posts: 4
Is very difficult to work with hibernate if I can't make unions and declare constants.

Another solution is to make 2 querys, and with java add the constants. It's not beautiful, but it works.

Is there another solution with hibernate?

A lot of thanks,

Marcial


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2003 2:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You must remember that Hibernate is a O/R mapping and provide APIs for the Object side of the O/R mapping.
IMO it's very relational to talk to constants and unions, since you don't use object request but flat select paramters.

_________________
Emmanuel


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