-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: session problem
PostPosted: Wed Jul 06, 2005 10:32 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 6:29 am
Posts: 24
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

I am using HibernateUtil written by chritianbauer for getting the session and Transaction I am Getting the error that session is closed
while excuting the following code.

public static String create(ICategory category)throws CategoryNotFoundException
{
if(category==null)
{
throw new CategoryNotFoundException("category Not Found");
}
String msg = "Category created";

category.setId(UniqueIdGenerator.getUniqueId());




try{
HibernateUtil.beginTransaction();
HibernateUtil.getSession().save(category);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
} catch(HibernateException ex)
{
System.out.println("Class CategoryManager Function: createCategory");
ex.printStackTrace();
msg= "category All ready Exists";

}

setRefreshed(true);






return msg;
} // end create






at java.lang.Thread.run(Thread.java:534)
Class CategoryManager Function: createCategory
org.hibernate.HibernateException: Session is closed
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:94)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:95)
at com.transversalnet.hibernate.HibernateUtil.commitTransaction(Hibernat
eUtil.java:182)
at com.transversalnet.docmanager.category.CategoryManager.create(Categor
yManager.java:215)
at com.transversalnet.docmanager.category.CategoryUtil.addRootCategory(C
ategoryUtil.java:38)
at com.transversalnet.servlets.docmanager.CategoryControllerServlet.doGe
t(CategoryControllerServlet.java:67)
at com.transversalnet.servlets.docmanager.CategoryControllerServlet.doPo
st(CategoryControllerServlet.java:154)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:198)


Name and version of the database you are using: mysql 4.0

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 9:03 pm 
Beginner
Beginner

Joined: Wed Jul 06, 2005 8:18 pm
Posts: 23
With 3.0, you no longer need to do this. Read
Quote:
http://www.hibernate.org/42.html
[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 07, 2005 2:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Tomcat is not a managed environment, so he still needs HibernateUtil. Since he doesn't show it we don't know what could be wrong in his implementation of it. He also doesn't care about "BEFORE POSTING" steps: http://www.hibernate.org/ForumMailingli ... AskForHelp


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 3:33 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 6:29 am
Posts: 24
Hi,

i am new to this J2EE so plz recoment should i use HibernateUtil or
simply use sessonfactory to getSession

regards
Arun


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.