public class PetDAO { public List<Pet> findNamedPetsBySpecies code example

Example: public class PetDAO { public List findNamedPetsBySpecies

public List<Pet> findNamedPetsBySpecies(Session session, String species) {
        List<Pet> results = new ArrayList<Pet>();
        String sql = "Select p from " + Pet.class.getName() + " p "//
               + " Where p.species = :species and name != null";
       Query<Pet> query = session.createQuery(sql);
       query.setParameter("species", species);
       results = query.getResultList();
        return results;
    }

Tags:

Misc Example