-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: DataIntegrityViolationException on a reference to a .....
PostPosted: Wed Dec 13, 2006 7:57 am 
Newbie

Joined: Tue Dec 12, 2006 6:35 pm
Posts: 19
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Spring 1.2.8

Mapping documents:
Copied below

Code between sessionFactory.openSession() and session.close():
Spring Hibernate 3 DAO

Full stack trace of any exception that occurs:

org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Could not execute JDBC batch update; SQL [insert into CMS_ContentItem_Entity (id, elt) values (?, ?)]; Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails"; nested exception is java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails"
org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:92)
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:258)
org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:371)
org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:690)
com.jafp.database.HibernateDao.saveOrUpdate(HibernateDao.java:26)

Name and version of the database you are using:
MySQL 4.1

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


Please help I am getting this error:

org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Could not execute JDBC batch update; SQL [insert into CMS_ContentItem_Entity (id, elt) values (?, ?)]; Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails"; nested exception is java.sql.BatchUpdateException: Duplicate key or integrity constraint violation message from server: "Cannot add or update a child row: a foreign key constraint fails"


My mappings are:

<class name="ContentItem" table="CMS_ContentItem">
<id name="id" column="id" type="integer" unsaved-value="0">
<generator class="native"/>
</id>
<property name="active"/>
<property name="status"/>
<property name="title"/>
<property name="description"/>


<!-- Complex types -->
<many-to-one name="itemType" class="Type"/>

<bag name="owners" table="CMS_ContentItem_Entity">
<key column="id"/>
<many-to-many class="Entity"/>
</bag>

<!-- Entity -->
<joined-subclass name="Entity" table="CMS_Entity">
<key column="id"/>

<property name="clubName"/>

<!-- Complex types -->
<set name="contact" table="CMS_Entity_Contact">
<key column="id"/>
<many-to-many class="com.jafp.objects.Contact" unique="true"/>
</set>

<set name="address" table="CMS_Entity_Address">
<key column="id"/>
<many-to-many class="com.jafp.objects.Address" unique="true"/>
</set>
</joined-subclass>
</class>


I have already set up a couple of entities in the database.

I am now trying to add a contentItem that is owned by an existing entity.

Is their an obvious reasons twhy this would break?

Thanks

Josh

_________________
_________________________
http://www.joshandfriends.com.au

Dance Music | Events | DJs


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.