-->
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.  [ 7 posts ] 
Author Message
 Post subject: Batch update row count wrong: 0 in Jboss+mysql+hibernate
PostPosted: Sat Jan 17, 2004 9:33 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
I'm using Jboss3.2.1 with Hibernate2.1 and MySql4(MySQL Connector/J 3.0) and these are my mapping file
For Class MemberHibernate

<hibernate-mapping>
<class name="com.netplus.pprincess.hibernate.MemberHibernate" table="MEMBERS">
...
...
<set name="faverites" table="FAVERITES" lazy="false" inverse="true" cascade="all"
sort="unsorted">
<key column="memberId"></key>
<one-to-many
class="com.netplus.pprincess.hibernate.FaveriteHibernate"
/>
</set>
......



For Class FaveriteHibernate


<hibernate-mapping>
<class
name="com.netplus.pprincess.hibernate.FaveriteHibernate"
table="FAVERITES"
>
<id
name="favId"
unsaved-value="null"
>
<generator class="assigned">
</generator>
</id>

<property
name="faverite"
type="java.lang.String"
column="faverite"
not-null="false"
unique="false" />

<property
name="memberId"
type="java.lang.Long"
column="memberId"
not-null="false"
unique="false"
/>
<!--
To add non XDoclet properties, create a file named
hibernate-properties-FaveriteHibernate.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>


My problem is once I try to set member's Faverite like this

faverite.setFavId(new Long(1));
faverite.setFaverite("faverite");
faverite.setMemberId(member.getMemberId());
member.getFaverites().add(faverite);


I have got this complain in Jboss terminal

20:32:42,425 ERROR [SessionImpl] 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:118)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:55)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:105)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:686)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:668)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:53)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2260)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2185)
at net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:52)
at com.netplus.hibernate.dao.impl.MemberDAOImpl.update(MemberDAOImpl.java:137)

Can anyone give me some suggestions, I've tried to look around in this forum but I can't get any idea, except set Batch_Size=0 ,however I really don't know how to set it in Jboss
service and this is my Jboss service file

-->
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=hibernate">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=MySqlDS</depends>
<attribute name="MapResources">com/netplus/pprincess/hibernate/AddressHibernate.hbm.xml,com/netplus/pprincess/hibernate/MemberHibernate.hbm.xml,com/netplus/pprincess/hibernate/FaveriteHibernate.hbm.xml</attribute>
<attribute name="JndiName">java:/PPrincessHibernateFactory</attribute>
<attribute name="Datasource">java:/PPrincessDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
</mbean>
</server>

Thanks so much

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2004 9:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
<attribute name="JdbcBatchSize">0</attribute>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2004 10:05 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Yeh thank mate, however, I got another complain after I set JdbcBatchSize

net.sf.hibernate.HibernateException: SQL update or deletion failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:714)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:668)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:53)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2260)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2185)

Thanks again

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2004 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please show a larger part of the code you are executing.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2004 9:12 pm 
Beginner
Beginner

Joined: Sun Sep 21, 2003 12:19 am
Posts: 40
http://forum.hibernate.org/viewtopic.php?t=926195&highlight= might or might not help. It is your id field in java class to be looked at first.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2004 11:26 pm 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
Thanks for all helps, I've already fixed my problem now with "unsaved_value=0".
Cheers

_________________
<name>arin</name>
<at>netplus software</at>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 4:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Added this one to the FAQ


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.