-->
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.  [ 3 posts ] 
Author Message
 Post subject: Could not synchronize database state with session
PostPosted: Wed Mar 02, 2005 3:56 pm 
Newbie

Joined: Thu Oct 07, 2004 3:53 pm
Posts: 10
I have a class, FandIGroupContainer, with a list of children, FandIGroup, which also has a list of children, FandIGroupMember.

Immediately after doing a load for the container, my code does a container.getGroups().clear(); which most of the time deletes all the groups and their members (see log of success below). However, seemingly ramdomly, it says "Could not synchronize database state with session", and "Batch update row count wrong: 0".

Any help would be greatly appreciated. Thanks!

Hibernate version: 2.1.8

Mapping documents:
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="com.poss.auto.shared.hib.model.fandi.FandIGroupContainer"
        dynamic-update="false"
        dynamic-insert="false"
        discriminator-value="0"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <discriminator
            column="discr"
            type="integer"
        />

        <property
            name="modelYear"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="modelYear"
        />

        <property
            name="startDate"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="startDate"
        />

        <list
            name="groups"
            table="FandIGroup"
            lazy="false"
            inverse="false"
            cascade="all-delete-orphan"
        >

              <key
                  column="container_id"
              >
              </key>

              <index
                  column="index"
              />

              <one-to-many
                  class="com.poss.auto.shared.hib.model.fandi.FandIGroup"
              />
        </list>

        <property
            name="active"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="active"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-FandIGroupContainer.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.BuyFandIContainer"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="1"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-BuyFandIContainer.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.LeaseFandIContainer"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="3"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-LeaseFandIContainer.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.CertPreOwnFandIContainer"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="2"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-CertPreOwnFandIContainer.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.NonMakePreOwnFandIContainer"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="5"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-NonMakePreOwnFandIContainer.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.MakePreOwnFandIContainer"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="4"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-MakePreOwnFandIContainer.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="com.poss.auto.shared.hib.model.fandi.FandIGroup"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="index"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="index"
        />

        <property
            name="discountAmount"
            type="float"
            update="true"
            insert="true"
            access="property"
            column="discountAmount"
        />

        <property
            name="discountPercent"
            type="float"
            update="true"
            insert="true"
            access="property"
            column="discountPercent"
        />

        <list
            name="members"
            table="FandIGroupMember"
            lazy="false"
            inverse="false"
            cascade="all-delete-orphan"
        >

              <key
                  column="grp_id"
              >
              </key>

              <index
                  column="index"
              />

              <one-to-many
                  class="com.poss.auto.shared.hib.model.fandi.FandIGroupMember"
              />
        </list>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-FandIGroup.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="com.poss.auto.shared.hib.model.fandi.FandIGroupMember"
        dynamic-update="false"
        dynamic-insert="false"
        discriminator-value="0"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
            </generator>
        </id>

        <discriminator
            column="discr"
            type="integer"
        />

        <property
            name="index"
            type="int"
            update="true"
            insert="true"
            access="property"
            column="index"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-FandIGroupMember.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.OptionNameFandIGroupMember"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="3"
        >

        <many-to-one
            name="optionName"
            class="com.poss.auto.shared.hib.model.option.OptionName"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="optionName"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-OptionNameFandIGroupMember.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.WarrantyFandIGroupMember"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="4"
        >

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-WarrantyFandIGroupMember.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.LifeInsuranceFandIGroupMember"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="2"
        >

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-LifeInsuranceFandIGroupMember.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="com.poss.auto.shared.hib.model.fandi.AccidentHealthFandIGroupMember"
            dynamic-update="false"
            dynamic-insert="false"
            discriminator-value="1"
        >

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-AccidentHealthFandIGroupMember.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs:
Code:
T: TP-Processor2 PN: vh1 URI: http://192.168.55.20/auto_admin/index.html
Cookies:
  PHPSESSID: c5a387a02b2081e49d624ff95cea9699
  portal: vh1
Params:
  container.modelYear: [2005]
  container.startDate: [03/09/2005]
  groups.discountAmount: [2.0, 5.0, 77.0]
  member_2: [370002]
  container.id: [782]
  ContainerClassName: [com.poss.auto.shared.hib.model.fandi.CertPreOwnFandIContainer]
  actions: [updateFandI]
  groups.discountPercent: [2.0, 44.0, 66.0]
  member_0: [99323, 370002, 99324]
  member_1: [99324]
PN from cookie: vh1
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroup set container_id=null, index=null where container_id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Mar 2, 2005 2:08:56 PM net.sf.hibernate.impl.SessionImpl execute
SEVERE: Could not synchronize database state with session
Mar 2, 2005 2:08:56 PM com.poss.auto.shared.web.ApplicationController processException
SEVERE: java.lang.RuntimeException: net.sf.hibernate.HibernateException: Batch update row count wrong: 0
        at com.poss.auto.shared.util.HibernateThreadLocalUtil.commitTransaction(HibernateThreadLocalUtil.java:158)
        at com.poss.auto.admin.handlers.action.update.UpdateFandIHandler.doIt(UpdateFandIHandler.java:110)
        at com.poss.auto.admin.handlers.action.update.UpdateFandIHandler.handleRequest(UpdateFandIHandler.java:89)
        at com.poss.auto.shared.web.ApplicationController.processActions(ApplicationController.java:43)
        at com.poss.auto.admin.AdminApplicationController.process(AdminApplicationController.java:44)
        at com.poss.auto.shared.web.DefaultServlet.doProcess(DefaultServlet.java:75)
        at com.poss.auto.shared.web.DefaultServlet.doPost(DefaultServlet.java:60)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
        at com.poss.auto.shared.web.TimeFilter.doFilter(TimeFilter.java:38)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
        at com.poss.auto.shared.web.VirtualPortalFilter.doFilter(VirtualPortalFilter.java:58)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:578)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
        at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
        at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:339)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:415)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:716)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:650)
        at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:829)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
        at java.lang.Thread.run(Thread.java:536)
Caused by: net.sf.hibernate.HibernateException: Batch update row count wrong: 0
        at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
        at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:128)
        at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
        at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:58)
        at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:111)
        at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:564)
        at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:29)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2435)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2397)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2261)
        at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
        at com.poss.auto.shared.util.HibernateThreadLocalUtil.commitTransaction(HibernateThreadLocalUtil.java:149)
        ... 42 more


Name and version of the database you are using: psql (PostgreSQL) 7.3.4-RH

The generated SQL (show_sql=true):
Code:
Here's what it looks like when it works:

T: TP-Processor7 PN: vh1 URI: http://192.168.55.20/auto_admin/index.html
Cookies:
  PHPSESSID: c5a387a02b2081e49d624ff95cea9699
  portal: vh1
Params:
  container.modelYear: [2005]
  container.startDate: [03/09/2005]
  groups.discountAmount: [2.0, 5.0, 77.0]
  container.id: [782]
  actions: [updateFandI]
  groups.discountPercent: [2.0, 44.0, 66.0]
  member_0: [99323, 370002, 99324]
  member_1: [99324]
  member_2: [370002]
  ContainerClassName: [com.poss.auto.shared.hib.model.fandi.CertPreOwnFandIContainer]
PN from cookie: vh1
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: update FandIGroup set container_id=null, index=null where container_id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroup where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroup where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroup where id=?


Debug level Hibernate log excerpt:

N/A


Top
 Profile  
 
 Post subject: More info here
PostPosted: Wed Mar 02, 2005 5:05 pm 
Newbie

Joined: Thu Oct 07, 2004 3:53 pm
Posts: 10
I get the same error (sometimes) when I iterate over the groups and just clear the members:
Code:
         container = FandIDao.loadFanidIGroupContainer(new Long(
            containerIdString));

         for (Iterator it = container.getGroups().iterator(); it.hasNext();) {
            FandIGroup g = (FandIGroup) it.next();
            g.getMembers().clear();

            HibernateThreadLocalUtil.getSales().commitTransaction();
            HibernateThreadLocalUtil.getSales().beginTransaction();
         }


Log with stack trace:

Code:
T: TP-Processor7 PN: vh1 URI: http://192.168.55.20/auto_admin/index.html
Cookies:
  PHPSESSID: c5a387a02b2081e49d624ff95cea9699
  portal: vh1
Params:
  container.modelYear: [2005]
  container.startDate: [03/09/2005]
  groups.discountAmount: [2.0, 5.0, 77.0]
  member_2: [370002]
  container.id: [782]
  ContainerClassName: [com.poss.auto.shared.hib.model.fandi.CertPreOwnFandIContainer]
  actions: [updateFandI]
  groups.discountPercent: [2.0, 44.0, 66.0]
  member_0: [99323, 370002, 99324]
  member_1: [99324]
PN from cookie: vh1
Hibernate: update FandIGroupMember set grp_id=null, index=null where grp_id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Hibernate: delete from FandIGroupMember where id=?
Mar 2, 2005 3:40:18 PM net.sf.hibernate.impl.SessionImpl execute
SEVERE: Could not synchronize database state with session
Mar 2, 2005 3:40:18 PM com.poss.auto.shared.web.ApplicationController processException
SEVERE: java.lang.RuntimeException: net.sf.hibernate.HibernateException: Batch update row count wrong: 0
        at com.poss.auto.shared.util.HibernateThreadLocalUtil.commitTransaction(HibernateThreadLocalUtil.java:158)
        at com.poss.auto.admin.handlers.action.update.UpdateFandIHandler.doIt(UpdateFandIHandler.java:116)
        at com.poss.auto.admin.handlers.action.update.UpdateFandIHandler.handleRequest(UpdateFandIHandler.java:90)
        at com.poss.auto.shared.web.ApplicationController.processActions(ApplicationController.java:43)



Top
 Profile  
 
 Post subject: Ignore this post
PostPosted: Wed Mar 02, 2005 6:36 pm 
Newbie

Joined: Thu Oct 07, 2004 3:53 pm
Posts: 10
I figured out the problem. I was forgetting to close my session.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.