Search within Object Relational Mapping
Register / Login
this forum made possible by our volunteer staff, including ...
Stephan van Hulst
Object Relational Mapping
Access a property from a collection in Hibernate
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
I have recently started working on Hibernate and there's a issue that I'm facing in regard to accessing a property from a query in hibernate.
<class name="CUser" table="C_USER"> <set name="CStudentDetails" inverse="true" lazy="true" table="C_STUDENT_DETAILS" fetch="select"> <key> <column name="STUDENT_ID" not-null="true" /> </key> <one-to-many class="CStudentDetail" /> </set> </class> <query name="findUserWherePermitted"> SELECT new CUser(cUser.name, cUser.emailId) FROM CUser cUser WHERE cUser.cStudentDetails.permit = ? </query>
Is this query correct? If not, what's the issue?
I feel the issue is that since cUser.cStudentDetails returns a set hence we cannot access cUser.cStudentDetails.permit. What is the way to make this access successful ?
Thanks & Regards,
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
Boost this thread!
how to save collection object into database
Querying tables with a one-to-many foreign key relationship
Error in named native query (Invalid Column Name)
Getting exception while passing List<Long> from hibernate to Stored Procedure
Foreig key must have same number of columns as the referenced primary key