-->
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: Batch update row count wrong: 0
PostPosted: Fri Sep 03, 2004 4:54 am 
Newbie

Joined: Tue Aug 24, 2004 8:41 am
Posts: 15
Location: Amersfoort, the Netherlands
Hibernate 2.1
MySQL 4.1.3

I have a problem in a <many-to-one cascade="all" name="address"/> association in the definition of 'BuyerOrganisation'.

- If I try to save BuyerOrganisation and flush the session I get an exception 'Batch update row count wrong: 0'
- If I don't flush at the end hibernate doesn't say anything but the address is not stored in the database, however the foreign key for address in the buyerorg table is set to 0 (which is the default before hibernate assigns an ID to it)
- If I save the address first and then the buyer organisation things go right.

It seems that it either doesn't cascade or it cascades the wrong way around (first the organisation then the address) Any idea what I could be doing wrong? Any help is appreciated.

Thanks,
Vincent

--
I have the following hibernate definition:

Code:
<hibernate-mapping package="nl.xiam.infomas.sx.model">

    <class name="BuyerOrganisation">
        <id name="id" column="buyerOrgID">
            <generator class="native"/>
        </id>
       
        <property name="name" length="32"/>
         
        <many-to-one name="address" cascade="all"/>

...mode defs....
       
    </class>
   
</hibernate-mapping>


And address:

Code:
<hibernate-mapping package="nl.xiam.infomas.bx.model">

    <class name="Address">
   
        <id name="id" column="addressID">
            <generator class="native"/>
        </id>
       
... all properties ...       
    </class>
   
</hibernate-mapping>




Code:
Session ses = _sessionFactory.openSession();
       
        BuyerOrganisation bo = new BuyerOrganisation();
        bo.setName("Some Org");
        Address a = new Address();
        a.setStreet("SomeStreet 32");
        a.setPostal("12345");
        a.setCity("Amersfoort");
        a.setCountry("NL");
        //ses.save(a);   // uncomment and things go right
        bo.setAddress(a);
       
        ses.save(bo);
        ses.flush();   // comment and it doesn't store the address, but doesn' t except either
        ses.disconnect();


I'm using spring and hibernate, but that doesn't matter.




Code:
SEVERE: Could not synchronize database state with session
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:126)
        at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
        at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2372)
        at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
        at nl.xiam.infomas.sx.command.PopulateDatabase.createBuyerAndOrganisation(PopulateDatabase.java:112)
        at nl.xiam.infomas.sx.command.PopulateDatabase.main(PopulateDatabase.java:63)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 5:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Might be easier to resolve this if you disable batch updates.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 03, 2004 5:53 am 
Newbie

Joined: Tue Aug 24, 2004 8:41 am
Posts: 15
Location: Amersfoort, the Netherlands
gavin wrote:
Might be easier to resolve this if you disable batch updates.


Yeah, I didn't even know you could turn that off (or on). Eventually I found out that I needed to set the 'unsaved-value' . Now it works. Thanks!


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.