-->
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: org.hibernate.jdbc.BatchedTooManyRowsAffectedException
PostPosted: Fri Aug 17, 2007 9:55 am 
Newbie

Joined: Fri Aug 17, 2007 9:47 am
Posts: 2
Location: USA
Hi all,

I am getting the above exception when i am trying to execute a simple test application.
The stack trace is as follows
log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
we are testing spring:: 11
we are testing spring:: org.springframework.context.support.FileSystemXmlApplicationContext@13a328f
we are testing spring and the application context is:: com.vecna.dms.ApplicationProperties@3a835d
we are testing spring and the application properties workflow bean is :: com.vecna.dms.bussiness.workflow.WorkFlowManagerImpl@aea710
the input straeem is : java.io.FileInputStream@6f8b2b
Hibernate: select max(id) from myname
Hibernate: insert into myname (name, id) values (?, ?)
org.springframework.orm.hibernate3.HibernateSystemException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1; nested exception is org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1
Caused by: org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:71)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:570)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:651)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:621)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:311)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy2.setTesting(Unknown Source)
at test.spring.SpringTest.main(SpringTest.java:38)






I am using the following:
1.Hibernate3
2.MySql5
3.I am using Spring for using hibernate
4.My mapping file is as follows
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.vecna.dms.persistence.Name" table="myname">
<id name="id" column="id"><generator class="increment" /></id>

<property name="name" type="string" column="name"/>
</class>
</hibernate-mapping>




5.My class is :


public class Name {
private String m_name;

private Long m_id;

public Long getId(){
return m_id;
}

public void setId(Long id){
m_id = id;
}

public String getName(){
return m_name;
}

public void setName(String name){
m_name = name;
}
}


My DataSource configuration are as follows.
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/dms</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>

Thanks
nagesh


Top
 Profile  
 
 Post subject: org.hibernate.jdbc.BatchedTooManyRowsAffectedException
PostPosted: Mon Aug 20, 2007 9:20 am 
Newbie

Joined: Mon Aug 20, 2007 9:09 am
Posts: 4
> insert
> into
> FACTURE
> (DATE_FACTURE, DESCRIPTION, numero)
> values
> (?, ?, ?) [13:37:09.812] org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:393)
> [DEBUG DateType] binding '20 août 2007' to parameter: 1 [13:37:09.828] org.hibernate.type.NullableType.nullSafeSet(NullableType.java:80)
> [DEBUG StringType] binding 'Facture B identifiée par 004' to parameter: 2 [13:37:09.843] org.hibernate.type.NullableType.nullSafeSet(NullableType.java:80)
> [DEBUG StringType] binding '004' to parameter: 3 [13:37:09.843] org.hibernate.type.NullableType.nullSafeSet(NullableType.java:80)
> Exception in thread "main" org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 7810893; expected: 1
> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:71)
> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
> at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
> at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
> at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
> 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:298)
> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
> at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
> at fr.mipih.commun.dao.HibernateFactureDao.store(HibernateFactureDao.java:194)
> at fr.mipih.commun.services.ServiceFacture.populateFactures(ServiceFacture.java:124)
> at fr.mipih.commun.Partie2.main(Partie2.java:22)



i have the following execption when i try to insert a sample record in database.
I'm using Hibernate 3.2 and Mysql 5.1.

Here is my class :

package fr.mipih.commun.domaine;

import java.io.Serializable;
import java.util.ArrayList;

import java.util.Date;
import java.util.Iterator;
import java.util.List;


public class Facture implements Serializable{
private static final long serialVersionUID = 1L;

private String numero;
private Date date;
private String description;
private List<LigneDeFacture> lignesDeFactures;

public Facture() {
this.lignesDeFactures = new ArrayList<LigneDeFacture>();
}

public Facture(String numero, Date date, String designation) {
this.numero = numero;
this.date = date;
this.description = designation;
}

public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public float getMontant() {
float montant = 0;
for (LigneDeFacture myligne : this.lignesDeFactures) {
montant += myligne.getMontant();
}
return montant;
}
public String getNumero() {
return numero;
}
public void setNumero(String numero) {
this.numero = numero;
}
@Override
public String toString() {
String endl = System.getProperty("line.separator");
List<LigneDeFacture> list = new ArrayList<LigneDeFacture>(lignesDeFactures);

float montant = 0;
String listeFacture = "";
Iterator it = list.iterator();
while (it.hasNext()) {
// Get element
LigneDeFacture myLigne = (LigneDeFacture) it.next();
montant += myLigne.getMontant();
listeFacture += myLigne.getDesignation() + " "+myLigne.getMontant()+ endl;
}
return (this.numero+ " " +this.date+" "+montant+endl+listeFacture);
}
public void ajouterLigneDeFacture(Facture myFacture, LigneDeFacture myLigne) {
myLigne.setNumerofacture(myFacture.numero);
myFacture.lignesDeFactures.add(myLigne);
}
public void ajouterUneLigne(LigneDeFacture myLigne) {
this.lignesDeFactures.add(myLigne);
myLigne.setNumerofacture(this.numero);
}
public void supprimerUneLigne(LigneDeFacture myLigne) {
this.lignesDeFactures.remove(myLigne);
myLigne.setNumerofacture("");
}

public void afficherLigneDeFacture(LigneDeFacture x){
Iterator it = lignesDeFactures.iterator();
while (it.hasNext()) {
// Get element
LigneDeFacture myLigne = (LigneDeFacture) it.next();
if (myLigne.compareTo(x) == 1)
System.out.println (myLigne.getDesignation()+" "+myLigne.getMontant());
}
}
public void afficherLigneDeFacture(){
System.out.println ("Affichage des lignes de la facture :" + this.getNumero());
Iterator it = this.lignesDeFactures.iterator();
while (it.hasNext()) {
// Get element
LigneDeFacture myLigne = (LigneDeFacture) it.next();
System.out.println (myLigne.getDesignation()+" "+myLigne.getMontant());
}
}
public void afficherLigneDeMaFacture(Facture myFacture){
System.out.println ("Affichage des lignes de la facture :" + myFacture.getNumero());
Iterator it = myFacture.lignesDeFactures.iterator();
while (it.hasNext()) {
// Get element
LigneDeFacture myLigne = (LigneDeFacture) it.next();
System.out.println (myLigne.getNumeroligne()+" "+myLigne.getDesignation()+" "+myLigne.getMontant());
}
}
public List<LigneDeFacture> getLignesDeFactures() {
return lignesDeFactures;
}

public void setLignesDeFactures(List<LigneDeFacture> lignesDeFactures) {
this.lignesDeFactures = lignesDeFactures;
}
@Override
public boolean equals(Object x) {
// La méthode se base sur le numéro de la facture
if( (x instanceof Facture) == false) {
return false;
}
Facture myFacture = (Facture)x;
return myFacture != null && myFacture.numero.equals(this.getNumero());
// return myFacture != null && myFacture.lignesDeFactures.equals(this.getLignesDeFactures()) && myFacture.numero.equals(this.getNumero());
}
public int hashCode() {
// Ici, la méthode se base uniquement sur le numéro pour
// déterminerl'égalité.
// La méthode equals() doit se baser les mêmes propriétés à savoir le numéro de facture
return this.getNumero().hashCode();
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

}

Here is my mapping file :

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="fr.mipih.commun.domaine">
<class name="Facture" table="FACTURE">
<id name="numero">
<!-- <column name="NUMERO" sql-type="varchar(10)" not-null="true" unique="true"/>-->
<generator class="assigned" />
</id>
<property name="date" type="date" column="DATE_FACTURE" />
<property name="description" type="string" column="DESCRIPTION" />
<!-- <bag name="lignesDeFactures" cascade="all,delete-orphan" inverse="true" lazy="true" fetch="join">
<key column="NUMERO_FACTURE"/>
<one-to-many class="fr.mipih.commun.domaine.LigneDeFacture" />
</bag> -->
</class>
<!-- [FIN:XML - configuration hibernate ] -->
</hibernate-mapping>



<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- [DEBUT:XML - hibernate configuration] -->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Affichage des requêtes SQL envoyées à la base + formatage -->
<property name="show_sql">false</property>

<!-- Le formatage des requêtes SQL demande à Hibernate de faire des retours chariots à la fin de chaque mot clef sql : SELECT, FROM, WHERE, ...etc -->
<property name="format_sql">true</property>

<!-- Fermer les connections en même temps que les transactions -->
<property name="connection.release_mode">after_transaction</property>

<!-- Collecte des statistiques pour le réglage des performances -->
<property name="hibernate.generate_statistics">true</property>

<!-- [FIN:XML - hibernate configuration] -->
<!-- local connection properties -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/FORMATIONJAVA</property>
<property name="hibernate.connection.username">FORMATIONJAVA</property>
<property name="hibernate.connection.password">FORMATIONJAVA</property>
<!-- <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> -->

<!-- Mapping files -->
<mapping resource="fr/mipih/commun/domaine/Facture.hbm.xml" />
<!-- <mapping resource="fr/mipih/commun/domaine/LigneDeFacture.hbm.xml" /> -->
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject: Re: org.hibernate.jdbc.BatchedTooManyRowsAffectedException
PostPosted: Tue Oct 30, 2007 11:36 am 
Newbie

Joined: Mon Aug 20, 2007 9:09 am
Posts: 4
nageshreddy wrote:
Hi all,

I am getting the above exception when i am trying to execute a simple test application.
The stack trace is as follows
log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
we are testing spring:: 11
we are testing spring:: org.springframework.context.support.FileSystemXmlApplicationContext@13a328f
we are testing spring and the application context is:: com.vecna.dms.ApplicationProperties@3a835d
we are testing spring and the application properties workflow bean is :: com.vecna.dms.bussiness.workflow.WorkFlowManagerImpl@aea710
the input straeem is : java.io.FileInputStream@6f8b2b
Hibernate: select max(id) from myname
Hibernate: insert into myname (name, id) values (?, ?)
org.springframework.orm.hibernate3.HibernateSystemException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1; nested exception is org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1
Caused by: org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 233258048; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:71)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:570)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:651)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:621)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:311)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy2.setTesting(Unknown Source)
at test.spring.SpringTest.main(SpringTest.java:38)






I am using the following:
1.Hibernate3
2.MySql5
3.I am using Spring for using hibernate
4.My mapping file is as follows
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.vecna.dms.persistence.Name" table="myname">
<id name="id" column="id"><generator class="increment" /></id>

<property name="name" type="string" column="name"/>
</class>
</hibernate-mapping>




5.My class is :


public class Name {
private String m_name;

private Long m_id;

public Long getId(){
return m_id;
}

public void setId(Long id){
m_id = id;
}

public String getName(){
return m_name;
}

public void setName(String name){
m_name = name;
}
}


My DataSource configuration are as follows.
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost/dms</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>

Thanks
nagesh

It was a problem with the Mysql Server i used.
Try the Mysql server 5.1.22 and your problem will disappear.


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.