I have the following schema in my hbm.xml file <hibernate-mapping> <class name="com.beans.MyTemplate" table="MyTemplate"> <composite-id name="key" class="com.beans.MyTemplatePk"> <key-property name="dataStoreId"/> <key-property name="name"/> </composite-id> <discriminator column="advanced" type="string"/> <property name="reportType"/> <subclass name="com.beans.SatReport" discriminator-value="A"> <property name="includeTableForAllGraphs"/> <list name="fileSizeBucketList" cascade="save-update" lazy="false"> <key not-null="true"> <column name="dataStoreId" /> <column name="name"/> </key> <list-index column="sortOrder"/> <many-to-many class="com.beans.TierBucket" column="key"/> </list> <list name="satReportSelections" cascade="all-delete-orphan" lazy="false"> <key not-null="true"> <column name="dataStoreId" not-null="true"/> <column name="name" not-null="true"/> </key> <list-index column="sortOrder"/> <composite-element class="com.beans.SatReportSelection"> <property name="key"/> <property name="selected"/> </composite-element> </list> </subclass> <subclass name="com.beans.SatBatReport" discriminator-value="C"> <property name="npv"/> <property name="chartStyle" type="string" not-null="true"> <column name="chartStyle" default="'Color Fill'"/> </property> <list name="fileAgeBucketList" cascade="save-update" lazy="false"> <key not-null="true"> <column name="dataStoreId" /> <column name="name"/> </key> <list-index column="sortOrder"/> <many-to-many class="com.beans.TierBucket" column="key"/> </list> <list name="satReportSelections" cascade="all-delete-orphan" lazy="false"> <key not-null="true"> <column name="dataStoreId" not-null="true"/> <column name="name" not-null="true"/> </key> <list-index column="sortOrder"/> <composite-element class="com.beans.SatReportSelection"> <property name="key"/> <property name="selected"/> </composite-element> </list> </subclass> </class> </hibernate-mapping>
The two subclasses SatReport and SatBatReport have the same lists fileSizeBucketList and satReportSelections. I see the following error messages in the log file.
2009-05-07 13:52:37,157 ERROR hbm2ddl.SchemaUpdate: Unsuccessful: alter table fileAgeBucketList add constraint FKCCF1CFEB36E6E9B2 foreign key (dataStoreId, name) references MyTemplate 2009-05-07 13:52:37,157 ERROR hbm2ddl.SchemaUpdate: Constraint already exists in statement [alter table fileAgeBucketList add constraint FKCCF1CFEB36E6E9B2 foreign key (dataStoreId, name) references MyTemplate] 2009-05-07 13:52:37,157 ERROR hbm2ddl.SchemaUpdate: Unsuccessful: alter table satReportSelections add constraint FK54CF74C136E6E9B2 foreign key (dataStoreId, name) references MyTemplate 2009-05-07 13:52:37,157 ERROR hbm2ddl.SchemaUpdate: Constraint already exists in statement [alter table satReportSelections add constraint FK54CF74C136E6E9B2 foreign key (dataStoreId, name) references MyTemplate]
Any idea how to avoid these error messages? Saving and retrieving objects seem to work fine.
Thanks, Bindu
|