|
Hi everybody.
I am having a problem while using many-to-many with a unique constraint (so that the collection acts as one-to-many).
I have three classes - Orderline, OrderLineId, and Order. The class Orderline has a composite id of type OrderLineId and is mapped in two tables i.e. ORDERLINE and LINKTABLE. The class Order has a unidirectional one-to-many association with the class Orderline.
Here is my mapping - <hibernate-mapping> <class name="Orderline" table="ORDERLINE"> <composite-id name="id" class="OrderLineId"> <key-property name="lineId" column="LINEID"/> <key-property name="orderId" column="ORDERID"/> <key-property name="customerId" column="CUSTOMERID"/> </composite-id> <property name="name" column="NAME"/> <join table="LINKTABLE"> <key> <column name="LINEID"/> <column name="ORDER_ID"/> <column name= "CUSTOMERID"/> </key> <property name="typename" column="TYPENAME"/> </join>
</class>
<class name="Order" table="ORDERTABLE"> <id name="id" column="ORDER_ID" type="java.lang.Long"> <generator class="increment"/> </id> <property name="orderName" column="ORDER_NAME"/> <set name="orderLines" table="LINKTABLE"> <key> <column name="ORDER_ID"/> </key> <many-to-many class="Orderline" unique="true"> <column name= "LINED"/> <column name= "ORDERID"/> <column name= "CUSTOMERID"/> </many-to-many> </set> </class> </hibernate-mapping>
since I have a <join> tag, I am using many-to-many with a unique constraint. Am I supposed to add unique="true" in each column of a many-to-many tag?
Any help will be appreciated!!
Thank you.
|