• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

synchronize database state with session  RSS feed

 
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,

 
Bartender
Posts: 2651
18
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: 2651
18
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.
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!