-->
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.  [ 4 posts ] 
Author Message
 Post subject: Compound Key with two parent tables help
PostPosted: Wed Jan 11, 2006 11:14 am 
Newbie

Joined: Wed Jan 11, 2006 10:57 am
Posts: 2
Hibernate version:
3.0.5
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9.2.0.6.0
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am having trouble creating the correct mapping documents for the following legacy tables:


Code:
(parent)
CREATE TABLE doctors
(
  id numeric(10) NOT NULL,
  name varchar(30),
  CONSTRAINT doctors_pk PRIMARY KEY (id)
)
(parent)
CREATE TABLE patients
(
  id numeric(10) NOT NULL,
  name varchar(30),
  CONSTRAINT patients_pk PRIMARY KEY (id)
)
(children)
CREATE TABLE addresses
(
  id numeric(10) NOT NULL, <-- either the doctors.id or patients.id
  seq numeric(5) NOT NULL, <-- keeps track of the address sequence
  addr_type varchar(1) NOT NULL, <-- 'D' denotes doctor address, 'P' patients
  address_1 varchar(25),
  address_2 varchar(25),
  city varchar(25),
  state_code varchar(2),
  CONSTRAINT addresses_pk PRIMARY KEY (id, seq, addr_type)
)


I would like to be able to call doctors.getAddresses() and return a Set of Addresses associated with the doctor. Same with the patients. I have googled, read the documentation, searched the forum and can't seems to but it together.

Any help is appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 11:37 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Think this is what Chapter 5.1.20 is all about. You would do the join using a formula something like (where address.type='D' and address.id=id)

I'm afraid I haven't used them but might open up new ideas to you...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 6:34 pm 
Newbie

Joined: Wed Jan 11, 2006 10:57 am
Posts: 2
timrobertson100

something clicked and it put me on the right track. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 4:22 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Any chance you could post your mapping with the formula if you did it that way - I'd like to see an example of one working?
Glad it pointed you in the right direction.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.