-->
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.  [ 5 posts ] 
Author Message
 Post subject: Update and Delete are not working
PostPosted: Thu Sep 01, 2005 12:52 pm 
Newbie

Joined: Thu Sep 01, 2005 12:28 pm
Posts: 9
Hibernate version:
3.0.2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
16:20:11,233 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session
org.hibernate.HibernateException: Unexpected row count: -1 expected: 1
at
org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:32)
at
org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1972)
at
org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1899)
at
org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2139)
at
org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:27
4)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)
at
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at
de.itamtbw.v1207a3300.business.common.D030AdressdateiCommon.updateAdressdatei(D030AdressdateiCommon.java:202)

at
de.itamtbw.v1207a3300.business.logic.BH007BusinessLogic.logicBh007ToBh003(BH007BusinessLogic.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
de.itamtbw.v1207a3300.utils.FormUtilities.callBusinessLogic(FormUtilities.java:158)
at
de.itamtbw.v1207a3300.gui.actions.PBH007Action.execute(PBH007Action.java:73)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:534)

Name and version of the database you are using:
DB2

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Hi guys,

I have an object which I had loaded from the DB. Then in a different session I want to update the changed object. I am using saveOrUpdate(). So, Hibernate makes a select to see if there is already a Record with this id and after it finds it, makes an Update. However the update comes with the message I posted - that there are -1 updated rows.

I haven't configured any locks on the DB, it just uses what is in the DB itself. I tried the same with a plain SQL and it worked. Then I tried Insert and Delete with Hibernate. Insert was successfull, and the Delete failed with the same error: -1 affected rows.

Any help will be appreciated.
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 1:02 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
I think if you are updating object from different session, you should use
session.merge() instead of saveOrUpdate()


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 1:06 pm 
Newbie

Joined: Thu Sep 01, 2005 12:28 pm
Posts: 9
I will try that, but when I turn the parametrs Logging on, then it seems like everything should be OK. At least it works when I change the ID, it puts a new row in the Table.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 10:49 am 
Newbie

Joined: Thu Sep 01, 2005 12:28 pm
Posts: 9
OK. So I tried with merge() still the same result.

Then I did both the loading and the updating in the same session and it still gives me the same error.

Any other suggestions?
On Access it is working. Do I need to configure the DB2 something extra to be useful with Hibernate?

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 02, 2005 12:25 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
make sure the following is commented out for db2

<!--<property name="hibernate.use_sql_comments">true</property>-->

apparently it causes errors with db2

And, also make sure the correct dialect is getting loaded.


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