-->
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: Help with mapping of composite key containing composite FK
PostPosted: Mon Aug 31, 2009 9:21 am 
Newbie

Joined: Mon Aug 31, 2009 9:00 am
Posts: 1
I'm having some major difficulty in mapping a legacy data model without running into Exceptions and the like.

Here are my tables:

Code:
CREATE TABLE programs
(
   program_id int NOT NULL,
   /* other cols here */
   PRIMARY KEY (program_id)
)

CREATE TABLE databases
(
   program_id int NOT NULL,
   database varchar(20) NOT NULL,
   /* other cols here */
   PRIMARY KEY (program_id, database),
   FOREIGN KEY (program_id) REFERENCES programs(program_id)
)

CREATE TABLE db_tables
(
   program_id int NOT NULL,
   database varchar(20) NOT NULL,
   table_name varchar(20) NOT NULL,
   PRIMARY KEY (program_id, database, table_name),
   FOREIGN KEY (program_id, database) REFERENCES databases(program_id, database)
)


I have created POJOs for the Program, Database, and Table types. There is a POJO for each composite key as well - DatabaseKey: int programId, String database & TableKey: DatabaseKey dbKey, String name . All classes implement Serializable and contain proper equals and hashcode implementations. I currently only require read-only access to the data. The Program class contains a Set of Database objects and the Database class contains a Set of Table objects (as indicated by the relational model). I only need unidirectional access from Program => Database => Table, but bidirectional would be a nicety.

Any suggestions?

I'll try and post the contents of my Java classes and mapping files shortly, but I don't have access to them at the moment.

Thanks a ton!


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.