Hello everyone,
I am having problems persisting using detached parent-child Lists. Whenever I attempt to get() the parent object from the database and add a Child object, I am unable to persist the objects (see below). The system just hangs until it finally times out. Why is this occuring, how can I remedy it, and what am I missing?
Thanks in advance,
Mike M.
Code:
// Test ProjectOrder
ProjectOrder po = manager.getProjectOrderbyProjectID(id);
// Dummy task
Task t = new Task();
List<Task> l = new ArrayList<Task>();
/* This made it work once
po = new ProjectOrder();
po.setShortdesc("New Project");
*/
t.setTask("get it working");
t.setUsername("joe");
po.addTask(t);
//saveOrUpdate()
manager.modifyProjectOrder(po); // Error happens here
Hibernate version: v3.1.3
ProjectOrder.hbm.xml:Code:
<class name="ProjectOrder" table="ProjectOrder" lazy="false" >
<id name="projectid" column="projectid" type="integer" unsaved-value="0">
<generator class="increment" />
</id>
<property name="shortdesc" />
<property name="deptorgname" />
<property name="name" />
<list name="tasks" inverse="false" cascade="all,delete-orphan" lazy="false">
<key column="projectid" not-null="true" update="false" />
<index column="taskidx" />
<one-to-many class="Task" />
</list>
</class>
ProjectOrder.hbm.xml:Code:
<class name="ProjectOrder" table="ProjectOrder" lazy="false" >
<id name="projectid" column="projectid" type="integer" unsaved-value="0">
<generator class="increment" />
</id>
<property name="shortdesc" />
<property name="deptorgname" />
<property name="name" />
<list name="tasks" inverse="false" cascade="all,delete-orphan" lazy="false">
<key column="projectid" not-null="true" update="false" />
<index column="taskidx" />
<one-to-many class="Task" />
</list>
</class>
ProjectOrder.hbm.xml:Code:
<class name="Task" table="Task" lazy="false">
<id name="taskid" column="taskid" type="integer" unsaved-value="0" >
<generator class="increment" />
</id>
<many-to-one name="projectOrder"
column="projectid" not-null="true"
insert="false" update="false" />
<property name="username" type="string" />
<property name="task" type="string" />
</class>
Code between sessionFactory.openSession() and session.close():Full stack trace of any exception that occurs:Code:
Oct 19, 2006 8:47:46 AM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet asic.admin.AdminServlet threw exception
org.hibernate.exception.DataException: Could not execute JDBC batch update
at asic.admin.HibernateAdminManager.modifyProjectOrder(HibernateAdminManager.java:76)
at asic.admin.AssignCommand.execute(AssignCommand.java:127)
at asic.admin.AdminServlet.doPost(AdminServlet.java:57)
at asic.admin.AdminServlet.doGet(AdminServlet.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:693)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:660)
at org.apache.jsp.admin.index_jsp._jspService(index_jsp.java:147)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException
... 41 more
Oct 19, 2006 8:47:46 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.hibernate.exception.DataException: Could not execute JDBC batch update
at asic.admin.HibernateAdminManager.modifyProjectOrder(HibernateAdminManager.java:76)
at asic.admin.AssignCommand.execute(AssignCommand.java:127)
at asic.admin.AdminServlet.doPost(AdminServlet.java:57)
at asic.admin.AdminServlet.doGet(AdminServlet.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:693)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:660)
at org.apache.jsp.admin.index_jsp._jspService(index_jsp.java:147)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
The generated SQL (show_sql=true):Code:
Hibernate:
select
projectord0_.projectid as projectid0_0_,
projectord0_.shortdesc as shortdesc0_0_,
projectord0_.deptorgname as deptorgn3_0_0_,
projectord0_.name as name0_0_
from
ProjectOrder projectord0_
where
projectord0_.projectid=?
Hibernate:
select
tasks0_.projectid as projectid1_,
tasks0_.taskid as taskid1_,
tasks0_.taskidx as taskidx1_,
tasks0_.taskid as taskid4_0_,
tasks0_.projectid as projectid4_0_,
tasks0_.username as username4_0_,
tasks0_.task as task4_0_
from
Task tasks0_
where
tasks0_.projectid=?
Project order desc is: test
Hibernate:
select
max(taskid)
from
Task
Hibernate:
insert
into
Task
(username, task, projectid, taskidx, taskid)
values
(?, ?, ?, ?, ?)
Hangs hereDebug level Hibernate log excerpt:Code:
Oct 19, 2006 8:47:46 AM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at asic.admin.HibernateAdminManager.modifyProjectOrder(HibernateAdminManager.java:74)