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