I'm newbie with this framework and want to create this db schema from my *.hbm.xml...
________ ________ ________
| Task | |TaskAttr | |Attribute |
|----------| |---------- | |-----------|
|id | Composite |expDate | 1 one-to-one 1| name |
|name |<>--------------| |--------------------| id |
|expDate| 1 n | | |expDate |
|code | |-----------| |----------|
|----------|
here're my mappin xml's but doesn't work out.
Code:
<hibernate-mapping>
<class name="Task" table="tasks">
<id name="id" column="task_id" type="long" unsaved-value="null">
<generator class="hilo"/>
</id>
<property name="name" column="task_name" type="string" length="30" not-null="true"/>
<property name="code" column="task_code" type="string" length="30" not-null="true"/>
<property name="expirationDate" column="task_expirationDate" type="java.sql.Date" not-null="true"/>
<set name="taskAttributes" cascade="all" inverse="true" lazy="true">
<key column="taskAttribute_id">
<composite-element class="TaskAttribute"> <!-- class attribute optional -->
<property name="expirationDate" type="java.sql.Date"/>
<one-to-one name="attribute" class="Attribute"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="Attribute" table="attributes">
<id name="id" column="attribute_id">
<generator class="foreign"/>
<param name="property">taskAttribute</param>
</generator>
</id>
<property name="name" column="attribute_name" type="string" length="30" not-null="true"/>
<property name="expirationDate" column="attribute_expirationDate" type="java.sql.Date" not-null="true"/>
<one-to-one name="taskAttribute" class="taskAttribute" constrained="true"/>
</class>
</hibernate-mapping>