-->
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.  [ 5 posts ] 
Author Message
 Post subject: MySql subselect work around?
PostPosted: Mon Dec 08, 2003 12:28 pm 
Newbie

Joined: Sat Sep 06, 2003 8:49 pm
Posts: 8
Here is my mapping:
Code:
<hibernate-mapping>
   <class name="security.User"
         table="ice_user">

      <id name="name" column="userName" type="string" length="64">
         <generator class="assigned"/>
      </id>      
      
      <set name="roles" table="ice_user_roles">
         <key column="userName"/>
         <element column="roleName" type="string" length="64" not-null="true"/>
      </set>
   </class>   
</hibernate-mapping>


My question is this:
Will I EVER be able to make this query work in mysql
Code:
select user from security.User as user inner join user.roles as role where role = ?


I'm using inner join cause I've seen similar queries in the docs. I've had nothing but issues with this, I don't even know if the HQL is correct. Here is the exception I'm getting:
Code:
net.sf.hibernate.QueryException: collection of values in from clause: user0_.roles.elements [
                select user from security.User as user inner join user.roles as role where role = ?


I had something last night(the debug log printed what looked like valid sql) using elements in the from? clause, but mysql does not support subqueries. Essentially all I want to do is select all the users that contain a particular role in their roles set. This is just a set of strings, not really entities. Thanks in advance.

--m


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2003 2:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use Hibernate 2.1.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2003 5:09 pm 
Newbie

Joined: Sat Sep 06, 2003 8:49 pm
Posts: 8
epbernard wrote:
Use Hibernate 2.1.


Worked like a champ. Thanks!
--m


Top
 Profile  
 
 Post subject: workaround
PostPosted: Tue Apr 13, 2004 12:32 pm 
Newbie

Joined: Thu Nov 13, 2003 12:03 pm
Posts: 18
Location: France
Is there any workaround if using 2.0.3 ?
I'm thinking to switch to collection of entities instead of collection of values. Would it be the only way ?
Thanks.


Top
 Profile  
 
 Post subject: Re: workaround
PostPosted: Thu Apr 22, 2004 5:19 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
pierre-yves wrote:
Is there any workaround if using 2.0.3 ?
I'm thinking to switch to collection of entities instead of collection of values. Would it be the only way ?
Thanks.

Yep

_________________
Emmanuel


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