Hello!
In our project we use Hibernate Annotations and we want to use a many-to-many relation with an additional field.
For that reason we used the example provided in the
caveatemptor project:
CategorizedItem.hbm.xml. This is exactly what we need but not with an Mapping-XML since we are using annotations.
Code:
<hibernate-mapping package="org.hibernate.auction.model">
<class name="CategorizedItem"
table="CATEGORIZED_ITEM"
lazy="true">
<composite-id name="id" class="CategorizedItem$Id"
access="org.hibernate.auction.persistence.DirectSetAccessor"
unsaved-value="any">
<key-property name="categoryId"
access="field"
column="CATEGORY_ID"
length="16"/>
<key-property name="itemId"
access="field"
column="ITEM_ID"
length="16"/>
</composite-id>
<property name="dateAdded"
column="DATE_ADDED"
type="java.util.Date"
update="false"
not-null="true"
access="org.hibernate.auction.persistence.DirectSetAccessor"/>
<property name="username"
column="USERNAME"
type="string"
update="false"
not-null="true"
access="org.hibernate.auction.persistence.DirectSetAccessor"/>
<many-to-one name="category"
insert="false"
update="false"
not-null="true"
access="org.hibernate.auction.persistence.DirectSetAccessor"
column="CATEGORY_ID"/>
<many-to-one name="item"
insert="false"
update="false"
not-null="true"
access="org.hibernate.auction.persistence.DirectSetAccessor"
column="ITEM_ID"/>
</class>
</hibernate-mapping>
How does the correct object with annotations look like? We tried it a view times but it doesn't work! Can somebody help us?
Thanks in advance!
Best regards, Stefan