-->
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: Problem with Join Query
PostPosted: Tue May 20, 2008 12:07 am 
Newbie

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

I have the query below which returns a collection "Objects" instead of "Group". Any ideas on what I maybe doing wrong? When I look at the returned objects in a debugger, its actually an array containing 1 Group and 1 GroupRole object.

Code:
      Session session = sessionFactory.getCurrentSession();
      Query qry = session.createQuery(" from  Group grp " +
                              "       inner join grp.groupRoles as groupRole " +
                              " where groupRole.role.serviceId = :serviceId and " +
                              "       groupRole.role.roleId = :roleId ");
   
      qry.setString("serviceId", serviceId);
      qry.setString("roleId", roleId);

      List<Group> results = (List<Group>)qry.list();


Maps:

Group:

Code:
<hibernate-mapping>
    <class name="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>
        <property name="createDate" type="timestamp">
            <column name="CREATE_DATE" length="19">
                <comment></comment>
            </column>
        </property>
        <property name="createdBy" type="string">
            <column name="CREATED_BY" length="20">
                <comment></comment>
            </column>
        </property>
        <property name="companyId" type="string">
            <column name="COMPANY_ID" length="20">
                <comment></comment>
            </column>
        </property>
        <property name="parentGrpId" type="string">
            <column name="PARENT_GRP_ID" length="20">
                <comment></comment>
            </column>
        </property>

   
        <set name="groupRoles" cascade="all-delete-orphan" lazy="true" inverse="true">
            <key>
                <column name="GRP_ID" length="20" not-null="true">
                    <comment></comment>
                </column>
            </key>
            <one-to-many class="GroupRole" />
        </set>
               

    </class>
</hibernate-mapping>


GroupRole:

Code:
<hibernate-mapping>
    <class name="GroupRole" table="GRP_ROLE" >
        <comment></comment>
        <id name="grpRoleId" type="string">
            <column name="GRP_ROLE_ID" length="20" />
              <generator class="SequenceGenerator">
                 <param name="table">sequence_gen</param>
                 <param name="column">next_id</param>
                 <param name="attribute">GRP_ROLE_ID</param>
               </generator>
        </id>

        <many-to-one name="role" class="Role" fetch="select">
            <column name="ROLE_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>
        <many-to-one name="group" class=".Group" fetch="select">
            <column name="GRP_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </many-to-one>


        <property name="serviceId" type="string">
            <column name="SERVICE_ID" length="20" not-null="true">
                <comment></comment>
            </column>
        </property>       

        <property name="createDate" type="timestamp">
            <column name="CREATE_DATE" length="19">
                <comment></comment>
            </column>
        </property>

    </class>
</hibernate-mapping>


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.