Query query = session.createQuery("from Employee where firstName = :firstName and lastName = :lastName"); query.setParameter("firstName", "John"); query.setParameter("lastName", "Doe"); Listresults = query.list();
Query query = session.createQuery("from Employee where firstName = :firstName and lastName = :lastName"); query.setProperties(Collections.singletonMap("firstName", "John", "lastName", "Doe")); ListIn this example, the setProperties method is used to set the values of the named parameters. The values are passed in as a Map object where the keys are the parameter names and the values are the parameter values. The query is executed and the results are returned as a list of Employee objects. The org.hibernate Query class is part of the Hibernate package library.results = query.list();