|
|
Rank: Apprentice Coder Groups: Member
Joined: 9/17/2010 Posts: 21 Points: 57 Location: Brazil
|
Hey guys,
i've been suffering from problems with the connection pool lifecycle using Hibernate and Weborb. The root of the problem comes from my impossibility to close connection at end of the method because when weborb serializes the object, it will cause an exception, because entitymanager is already closed, making the connections in the pool leaks and then freezing my deployed app on Glassfish.
Is there any recommended way to deal with that?
Thanks in advance.
|
|
Rank: Administration Groups: Administration
, Member
Joined: 9/10/2009 Posts: 320 Points: 778 Location: US
|
Hi could you please share with us a simple use-case in order to reproduce the problem
|
|
Rank: Apprentice Coder Groups: Member
Joined: 9/17/2010 Posts: 21 Points: 57 Location: Brazil
|
Hi Cyril. I have a common JPA entity, like the one below. I start the EntityManagerFactory when the application starts. And acquire one EntityManager per request, but if I call em.close() on the end of the method, weborb throws an Exception saying it can't serialize the return because the EntityManager was already closed.
Is there any example of how to use Hibernate with Weborb without problems?
The entity: @javax.persistence.Entity @javax.persistence.Table(name="empresa_Empresa") public class EmpresaVO extends BusinessVO implements Serializable {
@Id @GeneratedValue public Integer idEmpresa; public String nome; /* Relacionamentos da Classe */ @ManyToOne @JoinColumns({@JoinColumn(name="empresaPai")}) public EmpresaVO objEmpresa;
@OneToMany(mappedBy="objEmpresa") public Collection filiais;
@OneToMany(mappedBy="objEmpresa") @LazyCollection(LazyCollectionOption.EXTRA) public Collection temCargo; }
|
|
Rank: Apprentice Coder Groups: Member
Joined: 9/17/2010 Posts: 21 Points: 57 Location: Brazil
|
I just got a solution using servlet listeners after weborbServlet, and coded it to close entitymanagers just after serialization.
Thanks anyway.
|
|
|
Guest |