-->
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.  [ 3 posts ] 
Author Message
 Post subject: how do I map a relation not on primary keys
PostPosted: Thu Dec 01, 2005 11:24 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
How do i map a relation between classes on different columns that the primary keys? [legacy db]

For instance, if I have class A with 2 prim keys: A1 and A2, and one normal column: A3.
Then I have class B with 1 prim key: B1 and a normal column: B2.

The relation ship is defined as: A2 = B1 and A3 = B2.

If I were to use a <bag> on class A:
Code:
<bag>
    <key>
        <column name="B1" />
        <column name="B2" />
    </key>
  </bag>


It would ofcourse map A1 to B1 and A2 to B2.

This is not what I want. :twisted:

Any idea what I'm missing?? Shouldn't I be able to map relations on whather columns I choose?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 02, 2005 11:24 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
your legacy db is not a "truly" relational db. In a relational db the relationships are defined using primary and foreign keys.
Keep in mind that (N)Hibernate is designed to map an object model over a relational database.
In my case the solution to a similar problem was to create a view in order to define the relation in terms of primary-foreign keys. Of course that complicates the updates as normally you can't update a view.

cheers,
Radu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 05, 2005 4:22 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
ok, thank you. I will have to work around the problem then!


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

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.