I have a JUnit 4 test case with the Spring @Transactional
annotation that saves an object, and then attempts to find it. The test case passes when I use this implementation:
@Override
public EventSummary findEventSummaryById(Integer id) {
return em.find(EventSummary.class, id);
}
It fails when I use this implementation (and then change which method I call in the test case):
@Override
public EventSummary findEventSummary(Integer id) {
Query query = em.createQuery("select es from EventSummary as es where es.id = :id");
query.setParameter("id", id);
EventSummary result = (EventSummary) query.getSingleResult();
return result;
}