-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate compared to JPA
PostPosted: Sun Sep 11, 2011 12:38 pm 
Newbie

Joined: Sat Sep 10, 2011 7:43 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.