Joined: Thu Apr 02, 2009 1:54 pm Posts: 2
|
Hi All,
I am using JPA in my application. I am trying to understand the relation between EntityManager and Connection. When I am executing a large transaction I am getting the "Could not open connection" sort of exceptions
My code looks like below
public class MyPersistence
{
private EntityManager em;
MyPersistence(EntityManager em)
{
this.em = em;
}
public void add(Object obj)
{
em.persist(obj);
}
public Object update(Object obj)
{
return em.merge(obj);
}
public void delete(Object obj)
{
em.remove(obj);
}
}
@Stateless
public class MySessionBean
{
@PersistenceContext
private EntityManager em;
public void doBusiness()
{
CustomObect obj = new CustomObect();
MyPersistence persistence = new MyPersistence(em) ;
persistence.add(obj);
obj = persistence.update(obj);
persistence.delete(obj);
em.flush();
}
}
when I invokes doBusiness() method from MySessionBean total how many connections will be opened and when will they closed.
I really appreciate if someone can helps me.
|
|