Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate session in glassfish 2.1

 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helllo:
i was wondering hoe can i get the hibernate sesison in glassfish 2.1 ??

i've been trying this code:

public class HibernateSessionFactoryUtil
{
private static final SessionFactory sessionFactory;

static
{
try
{
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch (Throwable ex)
{
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory()
{
return sessionFactory;
}
}


but when im using the getSessionFactory method , i get the following message:

javax.ejb.EJBException: Stateless SessionBean method returned without completing transaction
at com.sun.ejb.containers.BaseContainer.checkExceptionBeanMgTx(BaseContainer.java:3689)
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your code look like when you actually use this method? Do you actually make a call to beginTransaction and commit?
 
Camilo Diaz
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved:

rather than use the sesisonfactory to get a hibernate session, i used hibernateentitymanager.class this way:

Session hsession = ((HibernateEntityManager) em.getDelegate()).getSession();

then i can use the hibernate instance session hsession.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic