-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: findbyExample() problem
PostPosted: Tue Jun 24, 2008 6:12 am 
Newbie

Joined: Tue Jun 24, 2008 6:09 am
Posts: 1
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.