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 7 years ago
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,
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
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