-->
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: Hibernate Query Language
PostPosted: Mon Apr 12, 2010 11:50 am 
Newbie

Joined: Mon Apr 12, 2010 11:43 am
Posts: 1
Hi Friends,

I am able to write a query with simple select statement below:
Code:
<query name="com.model.Person.findByEmailAddress">
        <![CDATA[select p from Person p where p.emailAddress = ? ]]>
  </query>

But how to write same as above for the below db query:
Code:
select email_address from person where id in(select member from group_members
where group_id in(select group_id from  in(select group_id from group_categories where category='customer'));


This is my Hibernate-mapping file
Code:

<hibernate-mapping>

    <class name="com.luser.model.Group" table="groups">
        <!-- primary key -->
        <id name="id" type="string"/>

        <!-- data -->
        <property name="owner" not-null="true"/>

        <set name="members" table="group_members" access="field">
            <key column="group_id" not-null="true"/>
            <element column="member" type="string" not-null="true"/>
        </set>

        <set name="categories" table="group_categories" access="field">
            <key column="group_id" not-null="true"/>
            <element column="category" type="string" not-null="true"/>
        </set>
    </class>

    <query name="com.model.Group.findByOwner">
        <![CDATA[select g from Group g where g.owner = ? ]]>
    </query>

    <query name="com.model.Group.findByMember">
        <![CDATA[select g from Group g where ? in elements(members) ]]>
    </query>

</hibernate-mapping>


Please help,i am very new to hibernate.

Thanks,
RK


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.