@Override public Firma findById(long id) { entityManager = HibernateUtil.getEntityManager(); Firma result = entityManager.find(Firma.class, id); entityManager.close(); return result; }
@SuppressWarnings("unchecked") @Override public List<Firma> getAll() { entityManager = HibernateUtil.getEntityManager(); List<Firma> result = entityManager.createQuery("from Firma").getResultList(); entityManager.close(); return result; }
@SuppressWarnings("unchecked") public List<Firma> findByFirmenName(String firmenName) { entityManager = HibernateUtil.getEntityManager(); Query query = entityManager.createQuery("from Firma f where f.firmenName = :firmenname"); List<Firma> result = query.setParameter("firmenname", firmenName).getResultList(); entityManager.close(); return result; }
public Firma findByFirmenName(String firmenName, String ansprechpartner) { entityManager = HibernateUtil.getEntityManager(); Query query = entityManager.createQuery( "from Firma f where f.firmenName = :firmenname and f.ansprechpartner = :ansprechpartner"); query.setParameter("firmenname", firmenName); Firma result = (Firma) query.setParameter("ansprechpartner", ansprechpartner).getSingleResult(); entityManager.close(); return result; }