hey guys.
i've got a strange behaviour with my native SQL-Query. What i want: i don't want to map scalar results afterwards in a for loop, instead i try to determine the objects in my query through addentity (see query below). well, it nearly works. i get my objects (user, permission, orgunit) and i can access their attributes and all (works right too). the only thing that makes me mad is, user , permission and orgunit hava all the same IDs. I checked with the database. The ID from User is right but Permission and Orgunit don't have the right ones. They have the ID's from User. I also executed the query in mysql-console. the query itself works... Any Ideas? Maybe the failure is obvious...;)
List<Object[]> list1 = session.createSQLQuery("select user.id,user.email, user.firstname,user.lastname,user.passwordsha1,user.username,user.usertype , permission.id, permission.name, orgunit.id, orgunit.full_name, orgunit.name,orgunit.hierarchy_id,orgunit.parent_id from " + "(((user_orgunit natural join user_permission ) join user on user_id=user.id) join permission on permission_id = permission.id) join orgunit on orgunit.id = orgunit_id where permission.name in (:null)").addEntity(User.class).addEntity(Permission.class).addEntity(OrgUnit.class).setParameterList("null", nullValues).list();
|