-->
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: problem with associations
PostPosted: Mon Jun 21, 2004 1:28 pm 
Newbie

Joined: Mon Jun 21, 2004 11:56 am
Posts: 8
We have this legacy DB with two tables as follows:

Code:
TableA {
columnA PK;
columnB PK;
columnC;
columnD;
}

TableB {
columnC PK; //same as TableA.columnC
columnE PK;
columnF;
columnG;
}


and the relationship is that TableA.columnC = TableB.ColumnC

We also have objects defined for these that presently is used by a custom persistence framework.

Code:
public class A{
private int columnA;
private String columnB;
private int columnC;
private Date columnD;
private List listBs; //this contains a collection of class B
......
}

public class B{
private int columnC;
private int columnE;
private int columnF;
private Date columnG;
....
}


How do i map these?

As you can see above, A can have one to many Bs. But, B is related to A only by a non-key column of A. When I use a bag to map these, i get the following exception:

Code:
net.sf.hibernate.MappingException: Foreign key must have same number of columns as referenced primary key


How do I map this?


Top
 Profile  
 
 Post subject: Not supported by hibernate right now
PostPosted: Mon Jun 21, 2004 3:30 pm 
Newbie

Joined: Mon Jun 21, 2004 11:56 am
Posts: 8
ok, after searching and searching for half-a-day this is what i found.

http://forum.hibernate.org/viewtopic.ph ... criminator

Yes, it is an ugly relational model, i agree, but most of the times we developers don't have a say in how these DBAs design tables in legacy systems.

For now i am going to try and manage this relationship externally, but I hope that hibernate supports this soon.

I am voting for it here:

http://opensource.atlassian.com/project ... key=HB-806

If any of you have a similar problem, please vote.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 3:38 pm 
Newbie

Joined: Mon Jun 21, 2004 11:56 am
Posts: 8
When I tried to vote for it i noticed that this is one feature that has been rejected. Too bad, my temporary code that manages this relationship externally is going to be permanent i guess.


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.