What is the difference between a session and a transaction in JPA 2.0?

前端 未结 4 1793
终归单人心
终归单人心 2020-12-23 11:30

I just begin my JPA 2.0 studies, and I have this piece of code:

em = SessionFactory.startSession();
tx = em.getTransaction();

My problem is

4条回答
  •  长情又很酷
    2020-12-23 11:57

    em = SessionFactory.startSession();
    

    In JPA, there is no Session and no SessionFactory. SessionFactory is a hibernate-specific interface that you shouldn't use if you use JPA (use either Hibernate's own API or use Hibernate as JPA Provider, but not both.)

提交回复
热议问题