Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.2.2
Name and version of the database you are using:
MySQL 4.1.22
The generated SQL (show_sql=true):
Hibernate: select contact0_.id as id1_0_, contact0_.number as number1_0_, contact0_.email as email1_0_, contact0_.website as website1_0_ from CMS_Contact contact0_ where contact0_.id=?
Hibernate: delete from CMS_ContentItem_Company where id=?
Hibernate: delete from CMS_ContentItem_Classification where id=?
Hibernate: delete from CMS_ContentItem_Feedback where id=?
Hibernate: delete from CMS_ContentItem_ContentItem where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Feedback where id=?
Hibernate: delete from CMS_Entity where id=?
Hibernate: delete from CMS_ContentItem where id=?
2007-03-29 20:26:28,796 WARN httpWorkerThread-8141-1 - SQL Error: 1217, SQLState: 23000
2007-03-29 20:26:28,812 ERROR httpWorkerThread-8141-1 - Duplicate key or integrity constraint violation message from server: "Cannot delete or update a parent row: a foreign key constraint fails"
2007-03-29 20:26:28,843 ERROR httpWorkerThread-8141-1 - 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:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
......
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Caused by: java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Cannot delete or update a parent row: a foreign key constraint fails"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1540)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
... 74 more
Generated create statement from schema export:
CREATE TABLE `cms_contentitem` (
`id` int(11) NOT NULL auto_increment,
`active` tinyint(1) default NULL,
`status` int(11) default NULL,
`title` varchar(255) default NULL,
`description` text,
`feature` tinyint(1) default NULL,
`releaseDate` datetime default NULL,
`createdDate` datetime default NULL,
`createdBy` int(11) default NULL,
`modifiedDate` datetime default NULL,
`modifiedBy` int(11) default NULL,
`threadId` int(11) default NULL,
`imageName` varchar(255) default NULL,
`thumbnailName` varchar(255) default NULL,
`comments` varchar(255) default NULL,
`itemType` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `FKEFBCD4F6F80E36A6` (`itemType`),
CONSTRAINT `FKEFBCD4F6F80E36A6` FOREIGN KEY (`itemType`) REFERENCES `cms_type` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
I am getting a constraint error when trying to delete from this table.
Is their anything i can do to prevent schema export creating constraints?