I'm getting the following error from Hibernate during initialization:
Code:
Dec 11, 2006 11:45:31 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: alter table resource_location add index FK1209BCC6247E152C (resource_key), add constraint FK1209BCC6247E152C foreign key (resource_key) references resource (key_value)
Dec 11, 2006 11:45:31 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Cannot add or update a child row: a foreign key constraint fails (`scheduler/#sql-5e8_4d`, CONSTRAINT `FK1209BCC6247E152C` FOREIGN KEY (`resource_key`) REFERENCES `resource` (`key_value`))
Dec 11, 2006 11:45:31 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: alter table user_contact_method add index FKCDE0D8D4532CF626 (user_key), add constraint FKCDE0D8D4532CF626 foreign key (user_key) references user (key_value)
Dec 11, 2006 11:45:31 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Cannot add or update a child row: a foreign key constraint fails (`scheduler/#sql-5e8_4d`, CONSTRAINT `FKCDE0D8D4532CF626` FOREIGN KEY (`user_key`) REFERENCES `user` (`key_value`))
Dec 11, 2006 11:45:32 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Unsuccessful: alter table user_property add index FKC7D137C9532CF626 (user_key), add constraint FKC7D137C9532CF626 foreign key (user_key) references user (key_value)
Dec 11, 2006 11:45:32 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
SEVERE: Cannot add or update a child row: a foreign key constraint fails (`scheduler/#sql-5e8_4d`, CONSTRAINT `FKC7D137C9532CF626` FOREIGN KEY (`user_key`) REFERENCES `user` (`key_value`))
Dec 11, 2006 11:45:32 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
I'm somewhat new to Hibernate. Why is it creating indexes and FK's, and what sort of thing should I look for to solve this problem? My search of the web hasn't revealed any posts that seem to be relevant. I have created some indexes in MySql, but Hibernate adds some of its own. Could this be the cause of the error? Do I need to leave the index creation entirely to Hibernate, or is the cause elsewhere?
Here is the mapping file for Resource generated from xDoclet:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.silversky.scheduler.domain.Resource"
table="resource"
>
<id
name="key"
column="key_value"
type="java.lang.Long"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Resource.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="type"
length="45"
not-null="true"
/>
<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="description"
length="45"
/>
<property
name="startDate"
type="java.util.Date"
update="true"
insert="true"
column="start_date"
/>
<property
name="endDate"
type="java.util.Date"
update="true"
insert="true"
column="end_date"
/>
<property
name="status"
type="java.lang.String"
update="true"
insert="true"
column="status"
length="45"
not-null="true"
/>
<property
name="preferredImageId"
type="java.lang.String"
update="true"
insert="true"
column="preferred_image"
length="45"
/>
<set
name="locations"
table="resource_location"
lazy="false"
cascade="none"
sort="unsorted"
>
<key
column="resource_key"
>
</key>
<many-to-many
class="com.silversky.scheduler.domain.Location"
column="location_key"
outer-join="false"
/>
</set>
<property
name="preferredLocationName"
type="java.lang.String"
update="true"
insert="true"
column="preferred_location"
length="45"
/>
<property
name="shortName"
type="java.lang.String"
update="true"
insert="true"
column="shortName"
length="45"
not-null="true"
/>
<many-to-one
name="organization"
class="com.silversky.scheduler.domain.Organization"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="rsrc_org_key"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Resource.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
Any help would be greatly appreciated.