Hey,
Ich hab zwei Klassen, welche über eine many-to-one-Beziehung verbunden sind.
Das sieht folgendermaßen aus:
Code:
<composite-id class="MActiveId" mapped="true">
<key-property name="actorType" type="string">
<column name="ACTOR_TYPE" length="16" />
</key-property>
<key-property name="actorId" type="java.lang.Long">
<column name="ACTOR_ID" precision="22" scale="0" />
</key-property>
</composite-id>
<discriminator column="ACTOR_TYPE" length="16" type="string" />
<property column="ACTIVE_START" name="activeStart" type="timestamp"/>
<property column="ACTIVE_END" name="activeEnd" type="timestamp"/>
<subclass discriminator-value="MET" name="MeterActive">
<many-to-one name="actor" class="TfmsMeters" foreign-key="ACTOR_ID" column="ACTOR_ID" />
</subclass>
....
und
Code:
<class name="TfmsMeters" schema="tfms" table="TFMS_METERS">
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0"/>
<generator class="assigned"/>
</id>
<one-to-one cascade="all" class="MeterActive" fetch="select" name="meterActive" property-ref="actor" />
<many-to-one class="TfmsPresets" column="PRESET_ID" name="preset">
</many-to-one>
<property name="armNo" type="java.lang.Long">
<column name="ARM_NO" not-null="true" precision="22" scale="0"/>
</property>
<property name="name" type="string">
<column length="250" name="NAME"/>
</property>
<property name="CUser" type="string">
<column length="64" name="C_USER"/>
</property>
....
Ausgelesen kann alles werden, jedoch bekomm ich beim Einfügen eines neuen Objektes vom Typ TfmsMeters dauernd folgenden Fehler:
Code:
org.hibernate.exception.GenericJDBCException: could not insert: [PresetActive]
Caused by: java.sql.SQLException: Ungültiger Spaltenindex
Danke schon Mal :)