I am new to Spring and Hibernate and I have a problem mentioned as under...
I have a table
USER_MENU_RIGHTS
[ id(PK),userid(FK),menuid(FK),accessibility(Varchar ) ]
Data in the table as somewhat as follows...
ID USER_ID MENU_ID ACCESSIBILITY
24 18 3 false
25 18 4 false
26 18 5 false
27 18 6 false
30 19 2 false
29 19 1 false
32 19 4 false
35 19 7 false
In a java Class (Assembler ) I am using the following method which invokes findByExample() of USER_MENU_RIGHTS DAO.
Code:
public List loadUserRights(String userId)
{
try{
Users user = userService.findById(new Long(userId));
UserRights userRights = new UserRights();
userRights.setUsers(user);
List userList = userRightsService.findByExample(userRights);
return userList;
}catch(Exception e){}
return null;
}
Actually I want to get a list of records WHERE USER_ID = some user id like 18... but it returns all the records of the table ... and the hibernate generated sql query is a little weired ...
SELECT this_.ID AS ID4_0_, this_.MENU_ID AS MENU2_4_0_, this_.USER_ID AS USER3_4_0_, this_.ACCESSIBILITY AS ACCESSIB4_4_0_
FROM KU.USER_MENU_RIGHTS this_ WHERE (1=1)
Please help...