I'm writing an application that use Hibernate to query the database (SQL Server). Now I'm querying a link table for all Items.
The query looks like:
"FROM UserRole ur join ur.platformUser join ur.role join ur.company"
I need all the UserRoles objects in a list but when I query the above query I got a arrao of objects with UserRole, Role, Company and PlatformUser objects in it.
I only need the UserRole objects with the other objects in the UserRole object.
How can I solve this in Hiernate that I can cast the result to for ex. Arraylist<UserRole>?
I tried following syntax:
Query query = session.createSQLQuery("select * FROM UserRole ur join PlatformUser pu ON pu.userId = ur.userId join [Role] r ON r.roleId = ur.roleId join [Company] c ON c.companyId = ur.companyId").addEntity(UserRole.class);
With this line I got a List of UserRoles but all the underlying objects are NULL.
