-->
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: Could not synchronize database state with session
PostPosted: Mon Dec 10, 2007 8:55 pm 
Newbie

Joined: Mon Dec 10, 2007 8:50 pm
Posts: 7
Hey...
Iam using String as my primary id
here is my POJO

public class EmpDetailsVO extends ActionForm {
private String date;
private String consultant_name;
private String consultant_email = "";
private String consultant_phone;
....

Mapping file...
<hibernate-mapping>
<class name="main.java.org.beans.EmpDetailsVO" table="resources_table1">


<id name="consultant_email" column="consultant_email" type="java.lang.String" unsaved-value="">
<generator class="assigned" />
</id>

<property name="date" column="today_date" not-null="false"/>
.......

DAO class

Session session = HibernateUtil.getSessionFactory().openSession();
try{
Transaction tx = session.beginTransaction();
if(session.isOpen()||session.isConnected()){
session.save(empVO); tx.commit();
}
} catch (HibernateException e).......


When I execute I get ..

ERROR 2007-12-10 15:59:42,780 [http-8080-Processor25] (SessionImpl.java:2379) - 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:126)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at .......


I have been banging my head since 3 weeks...
Please let me know what's worng in the code


Top
 Profile  
 
 Post subject: Re: Could not synchronize database state with session
PostPosted: Mon Dec 10, 2007 9:48 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
rajani_aviator@yahoo.com wrote:
ERROR 2007-12-10 15:59:42,780 [http-8080-Processor25] (SessionImpl.java:2379) - 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:126)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at .......


I have been banging my head since 3 weeks...
Please let me know what's worng in the code



What happens if you change the unsaved value to null and set the email address to null at the begining?



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 11, 2007 7:03 pm 
Newbie

Joined: Mon Dec 10, 2007 8:50 pm
Posts: 7
I tried with that but ,it gives the same error :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 12, 2007 5:05 am 
Newbie

Joined: Wed Dec 12, 2007 4:55 am
Posts: 1
Hello,


<generator class="assigned" /> means that you need to assigned yourself the email address. Therefore try to use saveOrUpdate instead save.

Do you have any collections mapping and cascading property defined in your mapping ?

_________________
JS


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 12, 2007 6:31 pm 
Newbie

Joined: Mon Dec 10, 2007 8:50 pm
Posts: 7
No I dont have any collection mapping or cascading properties..
Its just simple (one table).

I generate the id and assign to it..
I tried with saveOrUpdate too it dint work


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.