Welcome Guest Search | Active Topics | Members | Log In | Register

Hibernate Support Options · View
ghosthack
Posted: Wednesday, November 30, 2011 6:25:40 AM
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.
Cyril
Posted: Thursday, December 01, 2011 9:11:49 PM
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
ghosthack
Posted: Tuesday, December 06, 2011 5:40:51 AM
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;
}
ghosthack
Posted: Thursday, December 08, 2011 11:18:14 AM
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.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v4.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.084 seconds.