I can't figure out what is wrong with my mappings. I'm getting the following Exception:
Code:
Exception in thread "main" net.sf.hibernate.MappingException: Foreign key must have same number of columns as referenced primary key
Start server side stack trace:
net.sf.hibernate.MappingException: Foreign key must have same number of columns as referenced primary key
at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:33)
at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:523)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:623)
last entries in debug log:
Code:
...
09:09:42,808 INFO Configuration:503 - processing foreign key constraints
... (other FKs process OK)
09:09:42,818 DEBUG Configuration:513 - resolving reference to class: com.*****.cc.objectlib.schedule.ScheduleState
Mapping for ScheduleState:
Code:
<class
name="com.*****.cc.objectlib.schedule.ScheduleState"
table="SCHEDULE">
<id name="id" type="java.lang.Long">
<column name="SCHEDULE_ID"/>
<generator class="sequence">
<param name="sequence">schedule_seq</param>
</generator>
</id>
<!-- properties deleted -->
<!-- associations -->
<!-- bi-directional many-to-one association to ScheduleSnapshotState -->
<many-to-one
name="scheduleSnapshotState"
class="com.*****.cc.objectlib.schedule.ScheduleSnapshotState"
not-null="true"
update="false"
insert="false">
<column name="SCHEDULE_SNAPSHOT_ID"/>
</many-to-one>
<!-- bi-directional one-to-many association to TariffScheduleState -->
<set
name="tariffScheduleStates"
lazy="true"
inverse="true"
cascade="all-delete-orphan">
<key>
<column name="SCHEDULE_SNAPSHOT_ID"/>
<column name="SCHEDULE_ID"/>
</key>
<one-to-many
class="com.*****.cc.objectlib.tariff.TariffScheduleState"/>
</set>
</class>
Mapping for ScheduleSnapshotState:
Code:
<class
name="com.*****.cc.objectlib.schedule.ScheduleSnapshotState"
table="SCHEDULE_SNAPSHOT">
<id name="id" type="java.lang.Long">
<column name="SCHEDULE_SNAPSHOT_ID"/>
<generator class="sequence">
<param name="sequence">schedule_snapshot_seq</param>
</generator>
</id>
<!-- properties deleted -->
<!-- associations -->
<!-- bi-directional one-to-many association to ScheduleState -->
<set
name="scheduleStates"
lazy="true"
inverse="true"
cascade="all-delete-orphan">
<key>
<column name="SCHEDULE_SNAPSHOT_ID"/>
</key>
<one-to-many
class="com.*****.cc.objectlib.schedule.ScheduleState"/>
</set>
</class>
Mapping for TariffScheduleState:
Code:
<class
name="com.*****.cc.objectlib.tariff.TariffScheduleState"
table="TARIFF_SCHEDULE">
<id name="id" type="java.lang.Long">
<column name="SEQ_ID"/>
<generator class="sequence">
<param name="sequence">tariff_schedule_seq</param>
</generator>
</id>
<!-- properties deleted -->
<!-- associations -->
<!-- bi-directional many-to-one association to ScheduleState -->
<many-to-one
name="scheduleState"
class="com.*****.cc.objectlib.schedule.ScheduleState"
not-null="true"
update="false"
insert="false">
<column name="SCHEDULE_SNAPSHOT_ID"/>
<column name="SCHEDULE_ID"/>
</many-to-one>
<!-- bi-directional many-to-one association to TariffState -->
<many-to-one
name="tariffState"
class="com.*****.cc.objectlib.tariff.TariffState"
not-null="true"
update="false"
insert="false">
<column name="TARIFF_ID"/>
</many-to-one>
</class>
Am I right to assume that the problem is in ScheduleState since that is the last entry in the debug log? If that is the case, then I can't find the problem. It looks to me like all both sides of the associations match up.
Any help would be appreciated. I'm using 2.0.3.
Eric