• Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronize database state with session

 
nami shekar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am getting this exception when i try to do insertion to DB using Hibernate


The exception is as follows:
(JDBCExceptionReporter.java:72) - Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"
ERROR [2011-09-14 01:17:45] [Thread-11] (AbstractFlushingEventListener.java:299) - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1007)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:354)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.tel.Database.DBAlarmCRUD.insert(NMSDBAlarmCRUD.java:110)
at com.tel.Fault.FaultEventHandler.handleEvent(NMSFaultEventHandler.java:100)
at com.tel.Fault.FaultTrapHandler.handleTrap(NMSFaultTrapHandler.java:62)
at com.tel.Fault.FaultTrapReceiver.run(NMSFaultTrapReceiver.java:204)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1492)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)



And in the insert method at this line : transaction.commit(); the exception is shown.



Thanks in advance,

 
Jan Cumps
Bartender
Posts: 2619
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Nami!


This is the direct cause of your problem:
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Duplicate entry '10.50.34.36-Authentication Failure' for key 'PRIMARY'"


You, or your software, is trying to put the text '10.50.34.36-Authentication Failure' in a database field that requires that all values are unique, and that field already contains that text in another record. You are violating a primary key constraint.

 
nami shekar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan Cumps,
Thank you for your reply

Say suppose i have hundred data to be inserted into DB
50 or 60 may get inserted without any probelm, and later i get this problem.
And few times without any problem the code works fine. Why is it so?
 
Jan Cumps
Bartender
Posts: 2619
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I moved your thread to our Object Relational Mapping forum. That is the right place for Hibernate questions.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!