Hi,
there are many topics on this subject, but I did not found a solution yet.
I have 2 tables: Product and OrderProduct. --------------------------- Product has columns: FI (PK) DI (PK) PR (PK) PRLV (PK) ARTNR NAME and some others... -------------------------- OrderProduct has columns: FI (PK) DI (PK) ORDERTYPE (PK) ASSORTMENT (PK) ARTNR (PK) SORT and some others... --------------------------
These two tables are not in any relation, do not have any foreign keys. What I am trying to do is to make a class mapping for OrderProduct like this:
<class name="OrderProduct" table="ORDERPRODUCT" lazy="false"> <composite-id> <key-property name="Firm" column="FI" /> <key-property name="Division" column="DI" /> <key-property name="OrderType" column="ORDERTYPE" /> <key-property name="OrderAssortment" column="ASSORTMENT" /> <key-property name="Artnr" column="ARTNR" /> </composite-id> <property name="Firm" column="FI" /> <property name="Division" column="DI" /> <property name="OrderType" column="ORDERTYPE" /> <property name="OrderAssortment" column="ASSORTMENT" /> <property name="Artnr" column="ARTNR" /> <property name="Preset" column="PRESET" /> <property name="Sort" column="SORT" /> <join table="PRODUCT" fetch="join"> <key> <column name="DI" /> <column name="FI" /> <column name="ARTNR" /> </key> <property name="ProductName" column="NAME" /> </join> </class>
And it fails with am error message "Foreign key (PRODUCT [DI, FI, ARTNR])) must have same number of columns as the referenced primary key (ORDERPRODUCT [FI, DI, ORDERTYPE, ASSORTMENT, ARTNR])". But I want just to make a join operation, it does not need to have a foreign key at all. In SQL it looks like this: SELECT ARTNR, PRESET, SORT, NAME, FROM ORDERTYPE op JOIN PRODUCT p ON op.ARTNR = p.ARTNR AND op.DI = p.DI AND op.FI = p.FI
|