Hibernate Criteria / Query on object properties

前端 未结 2 702
迷失自我
迷失自我 2021-02-06 06:04

I have a class AppUser;

class AppUser {
   private String firstName;
   private String lastName;
   //-- getters and setters
}

I a

2条回答
  •  醉酒成梦
    2021-02-06 06:18

    Query:

    Query q = session.createQuery(
        "SELECT s from Student s WHERE s.appUser.firstName=:firstName AND s.appUser.lastName=:lastName");
    q.setParameter("firstName", "John");
    q.setParameter("lastName", "Doe");
    

    For using Criteria, check this thread

    Also take a look at this page from hibernate docs

提交回复
热议问题