Hi,
besteht in hibernate die Möglichkeit in einer Tabelle eine Spalte (nicht primary key) der Tabelle A als foreign key der Tabelle B zu verwenden?
Beispiel:
So hab ich das, funktioniert aber nicht. Es wird kein foreign key constraint angelegt
besteht in hibernate die Möglichkeit in einer Tabelle eine Spalte (nicht primary key) der Tabelle A als foreign key der Tabelle B zu verwenden?
Beispiel:
Code:
<class name="ebooking.module.base.bean.system.SystemLocale" table="BASE_SYSTEM_LOCALE">
<id name="id" type="long">
<column name="ID" not-null="true"/>
<generator class="increment"/>
</id>
<property name="localeKey" type="string">
<column name="LOCALE_KEY" not-null="true" unique="true"/>
</property>
<property name="language" type="string">
<column name="LANGUAGE" not-null="true"/>
</property>
<property name="countryName" type="string">
<column name="COUNTRY_NAME" not-null="true"/>
</property>
<set name="countries" table="BASE_ADDRESS_COUNTRY" inverse="true" cascade="all-delete-orphan" lazy="true" sort="ebooking.module.base.hbm.HibernateComparator">
<key column="SYSTEM_LOCALE_KEY" property-ref="localeKey" unique="true"/>
<one-to-many class="ebooking.module.base.bean.address.Country"/>
</set>
</class>
Code:
<class name="ebooking.module.base.bean.address.Country" table="BASE_ADDRESS_COUNTRY">
<id name="id" type="long">
<column name="ID" not-null="true"/>
<generator class="increment"/>
</id>
<property name="name" type="string">
<column name="NAME" length="100" not-null="true"/>
</property>
<many-to-one name="systemLocale" column="SYSTEM_LOCALE_KEY" class="ebooking.module.base.bean.system.SystemLocale" cascade="all-delete-orphan" not-null="true" property-ref="localeKey"/>
<set name="counties" table="BASE_ADDRESS_COUNTY" inverse="true" cascade="save-update" lazy="true" sort="ebooking.module.base.hbm.HibernateComparator">
<key column="COUNTRY_ID"/>
<one-to-many class="ebooking.module.base.bean.address.County"/>
</set>
<!--
<set name="counties" table="BASE_ADDRESS_COUNTY" cascade="all">
<key column="ADDRESS_COUNTRY_ID"/>
<one-to-many class="ebooking.module.base.bean.address.County"/>
</set>
-->
</class>
So hab ich das, funktioniert aber nicht. Es wird kein foreign key constraint angelegt