I have 3 tables
The first one:
PRODUCTS
-------------------
id
name
-------------------
The second one:
_____________
SPECIFICATIONS
---------------------------
id
name
dat
beg_dat
end_dat
____________
the link between them is many-to-many, but the "link table" must have not 2 fields(product_id,specification_id). It should have structure like this
LINKSPECPROD
----------------------------
ID*
----------------------------
spec_id
---------------------------
product_id
---------------------------
price
---------------------------
How can i do it?
ps
my mapping files are:
<class name="tables.Product" table="PRODUCTS">
<id name="id" column="PRODUCT_ID" type="long">
<generator class="native"/>
</id>
<property name="name" type="string" length="30" not-null="true" />
<set name="specifications" table="LinkSpecProd">
<key column="product_id"/>
<many-to-many class="tables.Specification">
<column name="spec_id"/>
</many-to-many>
<!--<many-to-many column="spec_id" class="tables.Specification/>-->
</set>
</class>
<class name="tables.Specification" table="SPECIFICATIONS">
<id name="id" column="ID" type="long">
<generator class="native"/>
</id>
<property name="name" type="string" length="30" not-null="true" />
<property name="dat" type="timestamp" not-null="true" />
<property name="beg_date" type="timestamp" not-null="false" />
<property name="end_date" type="timestamp" not-null="false" />
<set name="products" table="LinkSpecProd" inverse="true">
<key column="spec_id"/>
<!--<many-to-many column="product_id" class="tables.Product"/>-->
<many-to-many class="tables.Product">
<column name="product_id"/>
</many-to-many>
</set>
</class>
TIA, Constantine.
|