Is my way of using the entitymanager correct?
Code:
EntityManager entityManager = getEntityManagerFactory().createEntityManager();
Query query = entityManager.createQuery("SELECT a FROM Appointment a WHERE a.active = true AND a.startDate = :selectedDate");
Calendar selectedCalendar = getSelectedCalendar();
query.setParameter("selectedDate", selectedCalendar.getTime(), TemporalType.DATE);
ArrayList<Appointment> appointments = (ArrayList<Appointment>)query.getResultList();
QueueHelper.unproxyAppointments(entityManager, appointments);
entityManager.close();
getEntityManagerFactory() gets the static EntityManagerFactory.
I assume that the query is gone after this. Why is the querystring. Not exactly this but the by hibernate created string with things like "select doctype0_.id as id120_0_, ...".