• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Could not synchronize database state with session

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
A tiny monkey bit me and I got tiny ads:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic