Hi
In the past I have used the SessionFactory and the Hibernate Criteria eg
Code:
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(Thingy.class);
criteria.add(Restrictions.eq("theKey.id", 4);
criteria.add(Restrictions.eq(()));
criteria.add(Restrictions.eq();
criteria.addOrder(Order.desc();
return criteria.list();
But when I started to use Spring Webflow I noticed there is an emphasis on JPA eg
Code:
@Transactional(readOnly = true)
public class ThingyDao {
private EntityManager em;
@PersistenceContext
public void setEntityManager(EntityManager em) {
this.em = em;
}
@Transactional(readOnly = true)
public List<ThingyDto> loadByYear(int year) {
return em.createQuery("select thingy from Thingy thingy").getResultList();
}
My question is: is there a move towards JPA and away from Hibernate in projects such as Spring?
From a career perspective is it better to use JPA and remain more "open" in terms of standards?
Secondly I am trying to render a webflow JSP page and avoid the LazyInitializationException and cannot seem to find any examples that use HibernateFlowExecutionListener. The only examples in the Spring code are JPAFlowExecutionListener.
Does this also indicate a move towards JPA ?
Thirdly: I notice it's possible to inject the @PersistenceContext EntityManager but I have not seen the equivalent of org.hibernate.Session (?)
But I also noticed that it's possible to obtain the Session from the EntityManager by doing Session session = (Session) em.getDelegate();
Is there some kind of "roadmap" that indicates what is best practice or does it depend whether you're following jboss or Hibernate or EJB ?
Thanks
PS I mistakenly posted this question earlier in the OGM section