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