Mapping documents:
Hi every one!
Ive got a problem with mapping inheritance:
User.hbm.xml(This xml file, contains mapping for both user and lab classes, lab extends user):
<hibernate-mapping>
<class
name="akschap.User"
table="users"
>
<id
name="userId"
type="long"
column="USER_ID"
length="10"
>
<generator class="native" />
</id>
<one-to-one
name="address"
class="akschap.Address"
cascade="all"/>
<property
name="password"
type="string"
column="PASSWORD"
not-null="true"
length="20"
/>
<property
name="type"
type="string"
column="TYPE"
not-null="true"
length="3"
/>
<property
name="email"
type="string"
column="EMAIL"
not-null="true"
length="20"
/>
<property
name="tel"
type="long"
column="TEL"
not-null="true"
length="8"
/>
<property
name="name"
type="string"
column="NAME"
not-null="true"
length="20"
/>
<property
name="username"
type="string"
column="USERNAME"
not-null="true"
length="20"
/>
<joined-subclass
name="akschap.Lab"
table="labs">
<key column="LAB_ID"/>
<set name="errors" inverse="true" cascade="all-delete-orphan" ></joined-subclass>
</class>
</hibernate-mapping>
---------------
the thing is, i want my error mapping to look like thise,hence, i want a bidirectional(not unidirectional) relationship between "lab" and "error":
<hibernate-mapping>
<class
name="akschap.Error"
table="errors"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<id
name="errorId"
type="java.lang.Long"
column="ERROR_ID"
length="10"
>
<generator class="native" />
</id>
<property
name="errorNumber"
type="string"
column="ERROR_NUMBER"
not-null="true"
length="20"
/>
<property
name="description"
type="string"
column="DESCRIPTION"
not-null="true"
length="500"
/>
<!-- bi-directional many-to-one association to Lab -->
<many-to-one name="lab" class="akschap.Lab" > <column name="LAB_ID" not-null="true" length="10"/> </many-to-one>
<!-- bi-directional many-to-one association to LabMachine -->
<many-to-one
name="labMachine"
class="akschap.LabMachine"
>
<column name="MACHINE_ID" not-null="true" length="10"/>
</many-to-one>
</class>
</hibernate-mapping>
---------
sadly, this seems to be impossible.
error can not be mapped to lab, because lab is undefined in the congiguration file.
So, how can i have a bidirectional relationship between lab and error?
Please help me out!
Thanx:)
Neg
|