How to use the Entity Manager correctly?
Hello
I would like to ask a EntityManager related question. From the tutorials I have read I came across two different categories of examples in which EntityManager is used. In the first type it is like:
EntityManager em;
publicvoid addMethod(Object o)
{
em.persist(o);
}
whereas in the second type of examples, it is like:
EntityManager em;
publicvoid addMethod(Object o)
{
em.getTransaction().begin();
em.persist(o);
em.commit();
}
My question is, what is the difference between the two different approaches?
Thanks

