Register / Login
Win a copy of
Java 9 Revealed
this week in the
Features new in Java 9
this forum made possible by our volunteer staff, including ...
Roel De Nijs
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,
It is sorta covered in the
JavaRanch Style Guide
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