-->
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.  [ 4 posts ] 
Author Message
 Post subject: StaleStateException when saving an object
PostPosted: Tue Aug 01, 2006 8:27 am 
Newbie

Joined: Fri Jul 28, 2006 1:50 pm
Posts: 5
Name and version of the database you are using: mysql 5
Hibernate version: 3

Mapping documents:

<hibernate-mapping>
<class name="buildlistbytype.Debat" table="debat">
<id name="id" type="java.lang.Integer" column="id">
<generator class="increment"/>
</id>
<property name="description" column="description"/>
<list name="lstLiensSeance">
<key column="id"/>
<list-index column="list_index"/>
<one-to-many class="buildlistbytype.Passage"/>
</list>
</class>

<class name="buildlistbytype.Passage" table="debat_action" discriminator-value="PASSAGE">
<id name="id" type="java.lang.Integer" column="id">
<generator class="increment"/>
</id>
<discriminator column="action_type" type="java.lang.String"/>
<property name="datePassage" column="datePassage"/>
<subclass name="buildlistbytype.PassageCommission" discriminator-value="PASSCOM">
<property name="intitule" column="intituleCom"/>
</subclass>
<subclass name="buildlistbytype.PassageConference" discriminator-value="PASSCONF">
<property name="nbMembres" column="nb_membres_conf"/>
</subclass>
<subclass name="buildlistbytype.PassageSeance" discriminator-value="PASSSEANCE">
<property name="ordreJour" column="ordre_jour_seance"/>
</subclass>
</class>

</hibernate-mapping>

PassageConference, PassageCommission and PassageSeance are inherited from Passage. These 4 classes are differents actions that can be done on Debat (= debate, political discussion).


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

Debat deb=new Debat();
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(deb);
session.getTransaction().commit();
HibernateUtil.getSessionFactory().close();

Full stack trace of any exception that occurs:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at buildlistbytype.Main.main(Main.java:35)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)


Tables description :
sorry the tables names are in french

I have two tables : -debat (in english, debate or political discussion)
-debat_action, this one contains actions about the debate. If a debate is asked by a politician, it will be an new entry in this table. If a debate is evacuated, it will be another entry in this table for the debate.

I hope my explanation of the problem is quiet clear.

Thank you for helping

Bye


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 10:34 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
can't tell much from that little bit of code and log file. You sure its saying that on that save statement? I don't think it would talk about batch updates on saving an empty object.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: Fixed
PostPosted: Thu Aug 03, 2006 5:10 am 
Newbie

Joined: Fri Jul 28, 2006 1:50 pm
Posts: 5
I fix the problem.

I manipulated the id of the persistent super class "Passage" so Hibernate was confused between my id value and the id value of the database. I wrote the constructor of "Passage" with one parameter (the id).

I can not explain exactly what happened but If I dont modify the id, everything works perfectly.


Top
 Profile  
 
 Post subject: Fixed
PostPosted: Thu Aug 03, 2006 5:10 am 
Newbie

Joined: Fri Jul 28, 2006 1:50 pm
Posts: 5
I fixed the problem.

I manipulated the id of the persistent super class "Passage" so Hibernate was confused between my id value and the id value of the database. I wrote the constructor of "Passage" with one parameter (the id).

I can not explain exactly what happened but If I dont modify the id, everything works perfectly.


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