-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping Join
PostPosted: Mon Sep 27, 2010 7:24 am 
Newbie

Joined: Mon Sep 27, 2010 7:06 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.