-->
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.  [ 1 post ] 
Author Message
 Post subject: Could not execute JDBC batch update
PostPosted: Wed Jan 10, 2007 10:14 am 
Newbie

Joined: Wed Jan 10, 2007 9:02 am
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents:
Code:
<class name="com.othello.common.value.TimebasedMDValue" table="timebasedmd" lazy="false">
      <id name="id" type="string">
         <column name="id" sql-type="char(32)" not-null="true" />
         <generator class="uuid.hex" />
      </id>
      <property name="userId" type="string">
         <column name="userId" sql-type="char(32)" />
      </property>

      <property name="timecodeIn" column="timecodein" type="long" not-null="true" />
      <property name="timecodeOut" column="timecodeout" type="long" not-null="true" />
      <property name="isReferenced" column="isreferenced" type="boolean" />   
      <property name="referenceId" type="string">
         <column name="referenceid" sql-type="char(32)" />
      </property>
      
      <!--one-to-one cascade="all" name="data" column="dataid" class="com.othello.common.value.DataValue" property-ref="data"/ -->
      <many-to-one name="data" class="com.othello.common.value.DataValue" column="dataid" cascade="all" unique="true"/>
      <many-to-one name="clip" class="com.othello.common.value.AbstractClipValue" column="clipid" />
   </class>
<class name="com.othello.common.value.DataValue" table="data" lazy="false">
       <id name="id"  type="string">
            <column name="id" sql-type="char(32)" not-null="true">
               <comment>Primary ID of the data.</comment>
            </column>
            <generator class="uuid.hex" />
        </id>
      <discriminator column="datatype" type="string" />

      <property name="descriptorId" column="descriptorid" type="string" />
      <property name="timebasedMdId" column="tmdid" type="string" />
      <property name="parentId" column="parentid" type="string" />

      <!--
      <many-to-one name="descriptor" class="com.othello.common.value.DescriptorValue" lazy="false"/>
      <many-to-one name="timebasedMD" class="com.othello.common.value.TimebasedMDValue" column="tmd_id" unique="true" />
      <many-to-one name="parentData" column="data_id" class="com.othello.common.value.DataValue" />   
      -->
      <subclass name="com.othello.common.value.DCompositeValue" discriminator-value="composite">
         <set lazy="false" name="data" table="Data" cascade="all" inverse="true">
            <key column="dataid" />
            <one-to-many class="com.othello.common.value.DataValue" />
         </set>
      </subclass>
      <subclass name="com.othello.common.value.DTextValue" discriminator-value="text">
         <property name="text" type="string" column="text" />
      </subclass>
      <subclass name="com.othello.common.value.DKeywordValue" discriminator-value="keyword">
         <many-to-one name="keywordElement" cascade="none" class="com.othello.common.value.KeywordElementValue" />
      </subclass>
      <subclass name="com.othello.common.value.DPersonValue" discriminator-value="person">
         <property name="name" type="string" column="name" />
         <property name="role" type="string" column="role" />
      </subclass>
      <subclass name="com.othello.common.value.DTimedateValue" discriminator-value="timedate">
         <property name="timedate" type="calendar" />
      </subclass>

   </class>

<class name="com.othello.common.value.AbstractClipValue" table="AbstractClip">
      
      <id name="id" type="string">
         <column name="id" sql-type="char(32)" not-null="true" />
         <generator class="uuid.hex"/>
      </id>
      
      <discriminator column="cliptype" type="string" />
         
      <property name="name" type="string">
            <column name="name" />
        </property>
      
      <property name="binId" type="string">
         <column name="binid" sql-type="char(32)"/>
      </property>
      
        <property name="timecodeIn" type="long">
            <column name="timecodein" not-null="true" />
        </property>
       
        <property name="timecodeOut" type="long">
            <column name="timecodeout" not-null="true" />
        </property>
       
        <property name="numberFrames" type="long">
          <column name="numberframes" />
       </property>
       
      
       <property name="thumbnail" type="string">
          <column name="thumbnail" />
       </property>
       
        <set name="timebasedMetadata" table="TimebasedMD" cascade="delete-orphan" inverse="true">
          <key column="clipid" />
          <one-to-many class="com.othello.common.value.TimebasedMDValue"/>
      </set>
      
      <subclass name="com.othello.common.value.IngestClipValue">
         <property name="mediaPath" type="string">
               <column name="mediapath" />
           </property>
           <property name="frameRate" type="double">
               <column name="framerate" precision="0" scale="0" />
           </property>
           <property name="aspectRatio" type="double">
               <column name="aspectratio" precision="0" scale="0" />
           </property>
           <property name="dropFrame" type="boolean">
               <column name="dropframe" />
           </property>
            
      </subclass>
      
      <subclass name="com.othello.common.value.UserClipValue">
         <many-to-one
                name="parentClip"
                column="parentclipid"
              class="com.othello.common.value.IngestClipValue"
         />
      </subclass>
   </class>


Code between sessionFactory.openSession() and session.close():
Code:
logger.info("writeTimebasedData: ");
      try {
         Session session = currentSession();
         
         Transaction tx = session.beginTransaction();
         session.saveOrUpdate(timebasedData);
         tx.commit();
         
         AbstractClipValue clip = (AbstractClipValue) session.load(
               AbstractClipValue.class, clipId);
         clip.addTimebasedMetadata(timebasedData);
         
         tx = session.beginTransaction();
         session.update(clip);
         tx.commit();
         logger.info("writeTimebasedData: Successfully saved TimebasedMD");
         
      } catch (Exception ex) {
         logger.error("writeTimebasedData: Error Saving TimebasedMDValue", ex);
      }
      finally {
         closeSession();
      }


Full stack trace of any exception that occurs:
Code:
2007-01-10 13:06:52,234 <main> WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
2007-01-10 13:06:52,234 <main> ERROR org.hibernate.util.JDBCExceptionReporter - failed batch
2007-01-10 13:06:52,234 <main> ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at com.othello.api.dao.DaoMetadataService.writeTimebasedData(DaoMetadataService.java:256)
   at de.fhtw.othello.delegate.MetadataController.writeTimebasedData(MetadataController.java:140)
   at de.fhtw.othello.views.userclips.listener.CreateButtonListener.widgetSelected(CreateButtonListener.java:64)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at de.fhtw.othello.OthelloApplication.run(OthelloApplication.java:84)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.sql.BatchUpdateException: failed batch
   at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   ... 33 more
2007-01-10 13:06:52,285 <main> ERROR com.othello.api.dao.DaoMetadataService - writeTimebasedData: Error Saving TimebasedMDValue
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
   at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
   at com.othello.api.dao.DaoMetadataService.writeTimebasedData(DaoMetadataService.java:256)
   at de.fhtw.othello.delegate.MetadataController.writeTimebasedData(MetadataController.java:140)
   at de.fhtw.othello.views.userclips.listener.CreateButtonListener.widgetSelected(CreateButtonListener.java:64)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at de.fhtw.othello.OthelloApplication.run(OthelloApplication.java:84)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.sql.BatchUpdateException: failed batch
   at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
   at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
   ... 33 more


Name and version of the database you are using:
Hypersonic

The generated SQL (show_sql=true):
Code:
Hibernate: insert into timebasedmd (userId, timecodein, timecodeout, isreferenced, referenceid, dataid, clipid, id) values (?, ?, ?, ?, ?, ?, ?, ?)



Debug level Hibernate log excerpt:
Don't know where to find this.


I guess this problem happens when I try to create a TimebaseMDValue in the database with a dataValue object that is already used by another TimebasedMDValue. If the dataValue is null it can be created without any problems.


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

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.