Link to home
Start Free TrialLog in
Avatar of letsbedecent
letsbedecent

asked on

Hibernate Query By Example

Hello,
 
      can anyone tell me where i can find the documentation on this ??

      I searched for it , but couldnt find.

Thanks.
Avatar of zzynx
zzynx
Flag of Belgium image

Avatar of letsbedecent
letsbedecent

ASKER

Hey,

      Its not HQL i am asking about. Its Hibernate QBE ( a part of hibernate QBC).  I found documentation on QBC, but not QBE... thats what i am looking for.

Thank you.
nope
SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
User exampleUser = new User();
 exampleUser.setFirstname("Max");
 Criteria criteria = session.createCriteria(User.class);
 criteria.add( Example.create(exampleUser) );
 List result = criteria.list();
 
Thank you.,

  what if the exampleUser has a mapping to Office object.  (many to one). and now i want to get all users within the office of "Experts Exchange" having a name "mike"

??

Thank you.
I dont want to use HQL.

i want to use the hibernates capability of retrieving records by criteria  /  example.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Where do you specify the {alias} name ??
{alias} will be replaced with the name of the table (hibernta does it for you)
see: http://www.hibernate.org/hib_docs/v3/api/org/hibernate/criterion/Restrictions.html#sqlRestriction(java.lang.String)
:-)

Good luck!