-->
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.  [ 1 post ] 
Author Message
 Post subject: Need help with Join Query
PostPosted: Thu Apr 03, 2008 8:49 am 
Newbie

Joined: Thu Jan 24, 2008 1:35 am
Posts: 9
Hello,

I am trying to run the query below, which is supposed to return a list of "Group" objects. When I run it, I get a "Object" that contains a Group and a UserGroup object.

I need it to run a Group - what am I doing wrong that is preventing this from coming back a Group object?

Thanks



Code:
      
Session session = sessionFactory.getCurrentSession();
Query qry = session.createQuery("from Group as grp " +
                  " join grp.userGroups as userGroup " +
                  " where userGroup.user.userId = :userId ");
qry.setString("userId", userId);
List<Group> result = (List<Group>)qry.list();
if (result == null || result.size() == 0)
   return null;
return result;   


Hibernate version: 3.2

Mapping documents:


Code:
<hibernate-mapping>
    <class name="org.openiam.idm.srvc.grp.dto.Group" table="GRP" >
        <comment></comment>
        <id name="grpId" type="string">
            <column name="GRP_ID" length="20" />
            <generator class="assigned" />
        </id>
        <property name="grpName" type="string">
            <column name="GRP_NAME" length="40">
                <comment></comment>
            </column>
        </property>
.....
        <set name="userGroups" cascade="all-delete-orphan" lazy="true" fetch="join">
            <key>
                <column name="GRP_ID" length="20" not-null="true" />
            </key>
            <one-to-many class="org.openiam.idm.srvc.grp.dto.UserGroup" />
        </set>




Code:

<hibernate-mapping>
    <class name="org.openiam.idm.srvc.grp.dto.UserGroup" table="USER_GRP" >
        <comment></comment>
        <id name="userGrpId" type="string">
              <column name="USER_GRP_ID" length="20" />
              <generator class="org.openiam.base.id.SequenceGenerator">
                 <param name="table">sequence_gen</param>
                 <param name="column">next_id</param>
                 <param name="attribute">USER_GRP_ID</param>
               </generator>       
          </id>

......

        <many-to-one name="user" class="org.openiam.idm.srvc.user.dto.User" fetch="join">
            <column name="USER_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.