-->
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 to map a table without PK but containing a composite FK
PostPosted: Wed May 30, 2007 12:10 pm 
Newbie

Joined: Sun Sep 11, 2005 7:46 pm
Posts: 15
Hibernate version: 3.2.2

Name and version of the database you are using: MySQL 5.0.28

Here I have a weird legacy table, let me call it Table1. Table1 has two columns columnA and columnB, it does not have any primary key. ColumnA is the foreign key referencing the PK of Table2. ColumnA is not nullable. ColumnA and ColumnB together is a foreign key referencing the composite primary key of Table3. ColumnB is nullable. How to map this table? Table2 and Table3 are both already correctly mapped. I'm using JPA annotation. Thanks a lot for any help!


Ellen


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 1:04 pm 
Newbie

Joined: Sun Sep 11, 2005 7:46 pm
Posts: 15
forgot to say:

cardinality between Table1 and Table2: ManyToOne
cardinality between Table1 and Table3: ManyToOne

The PK of Table2, semantically ColumnA, is a part of the composite PK of Table3.

Thanks!

ellen


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 2:15 pm 
Beginner
Beginner

Joined: Fri May 18, 2007 10:28 am
Posts: 48
Location: Madison, WI
Can you fox hibernate saying column A is the primary key. If not as far as I know, I think it is not possible in Hibernate without a primary key column. The .equals and hashcode method base all their functionality based on the PK value.


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.