*
The moose likes Object Relational Mapping and the fly likes Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException" Watch "Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException" New topic
Author

Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException

suraj savaratkar
Ranch Hand

Joined: May 17, 2010
Posts: 67
I am Implementing a ModelDriven interface with its getModel() mehtod in Action class and passing an object of an bean(POJO) class
to save the bean object into DAO class with passing this object to method but it thrown an Exception like that



Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot add or update a child row:
a foreign key constraint fails (`changedftts/capabilitybuilding`, CONSTRAINT `FK_capabilitybuilding_2` FOREIGN KEY (`mentorID`)
REFERENCES `mentor` (`mentorID`) ON DELETE CASCADE ON UPDATE CASCADE)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1011)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2046)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1964)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1949)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1729)

what is reason for thrown an 'MySQLIntegrityConstraintViolationException'.
 
Consider Paul's rocket mass heater.
 
subject: Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException