-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem mit delete Befehl: BatchedTooManyRowsAffectedExcepti
PostPosted: Wed Sep 19, 2007 7:20 am 
Newbie

Joined: Fri Aug 17, 2007 7:43 am
Posts: 8
Hallo,

Ich habe schwierigkeiten beim Löschen von Daten aus der Datenbank.


Mit diesem Code möchte ich sätze aus den DB Tabellen Löschen, jedoch tut er das nicht und wirft eine Exception.

Code:
   public void deleteDepartmentByUser(User user, Department dep) {
      Session ses = HibernatePool.getSessionFactory("as400").openSession();
      try {
         Transaction tx = ses.beginTransaction();
         Query query = ses.createQuery("from UserInDepartment where idUser = :idUser and idDepartment = :idDepartment");
         query.setString("idUser", user.getIdUser());
         query.setString("idDepartment", dep.getIdDepartment());
         List lst = query.list();
         System.out.println("found: " + lst.size());
         for (int i = 0; i < lst.size(); i++) {
            UserInDepartment uid = (UserInDepartment) lst.get(i);
            ses.delete(uid);
            uid = null;
            ses.flush();
         }
         tx.commit();
      } catch (Exception e) {
         e.printStackTrace();
      }
      ses.close();
   }   


Code:
found: 1
Hibernate: delete from GXBS_UID where idUserInDepartment=?
- Exception executing batch:
org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned un
expected row count from update [0]; actual row count: 2; expected: 1
        at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expecta
tions.java:71)
        at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expect
ations.java:46)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.jav
a:68)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.jav
a:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
246)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)

        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)

        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at de.geis.webapps.gcc.userandpermissions.server.UserManager.deleteDepar
tmentByUser(UserManager.java:236)
        at de.geis.webapps.gcc.userandpermissions.UserManager.deleteDepartmentBy
User(UserManager.java:18)
        at de.geis.webapps.gcc.userandpermissions.UserAdapter.doDepartmentDelete
(UserAdapter.java:310)

[ ... ]


Wenn ich direkt in die Datenbank schaue ist der Satz auch noch vorhanden. Auch wenn ich mir aus der Session direkt die JDBC Connection hole und einen DELETE SQL Befehle absende bleibt der Satz unberührt.


Ist so ein (fehl)verhalten bekannt? Kann das an der Konfiguration liegen?

Das Kuriose ist das er es manchmal ohne Probleme macht, aber überwiegend bekomme ich diese Exception.


mfg,
Michael Schmuck


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 7:35 am 
Newbie

Joined: Fri Aug 17, 2007 7:43 am
Posts: 8
Hallo,

zusätzlich habe ich festgestellt, das ohne c3p0-Pool der Satz gelöscht wird, aber auch die gleiche Fehlermeldung erscheint.


mfg,
Michael


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