I'm new to persistence frameworks, and wonder whether to use Java Persistence API or Hibernate in my Java Desktop application.
JPA:
Code:
EntityManager em = Persistence.createEntityManagerFactor ("MyProjectPU").createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(myObject);
tx.commit();
Hibernate:
Code:
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
Transaction tx = session.beginTransaction();
session.save(myObject);
tx.commit();
What's the difference between these two ways of saving an object? Why should I use JPA? Why should I use Hibernate?
Thanks in advance!
Trygve