aspose file tools*
The moose likes Object Relational Mapping and the fly likes Could not synchronize database state with session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Could not synchronize database state with session" Watch "Could not synchronize database state with session" New topic
Author

Could not synchronize database state with session

Haricharan Maramraj
Greenhorn

Joined: Dec 19, 2004
Posts: 6
Hi Everyone:

Could anyone tell me why I could save an object from java with the help of Hibernate? I am getting the following error message:

Dec 27 15:42:41 ERROR {JDBCExceptionReporter.java:58} - DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null
Dec 27 15:42:41 ERROR {SessionImpl.java:2399} - Could not synchronize database state with session
net.sf.hibernate.exception.ConstraintViolationException: could not insert: [com.averitt.DataLayout#1000]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1332)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:474)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:438)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:37)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2391)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
at com.averitt.EventManager.testCreateAndRead(EventManager.java:294)
at com.averitt.EventManager.setUp(EventManager.java:195)
at com.averitt.EventManager.main(EventManager.java:307)
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

There is nothing complicated in my class except few getters and setters. And the corresponding table in DB2 has id which is not null and primary key. I also made sure that I am passing ID which is unique and not null while saving the object.

I appreciate your time and effort.

Thankyou
Haricharan M.
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
i can not tell from just the exception. can you show the mapping, the object you want to insert and the code where you insert the object ?


pascal
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
ok.... i found a hint on this page

the error code means:
Conversion error on input host variable &2;

so perhaps you are mapping to the wrong datatype ?
is your DB Dialect set correct in hibernate properties ?

pascal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could not synchronize database state with session
 
Similar Threads
Error Code
getNextException SQLGrammarException
insert data into 2 tables using HQL
ConstraintViolationException in Hibernate
Hibernate3.0 with DB2 8.1.3UDB - org.hibernate.exception. SQLGrammarException