-->
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: Mapping 1 to many
PostPosted: Tue Nov 02, 2004 4:08 pm 
Beginner
Beginner

Joined: Tue Jun 22, 2004 7:50 am
Posts: 25
I'm working with an existing badly designed database.

The problem is that some tables aren't normalised and others are over normalised.

I'd rather not continue these errors into my objects (and in any case I wouldn't want to map my objects 1-to-1 my tables even if they were perfectly designed.)

I've skimmed the Hibernat In Action and can't find how I would do this.

What I would like is map one of my classes to 2 tables: both tables are equal parts of the class *not* composite parts. So say my class is Car and one table defines a column "name" and the other table defines a column "colour" I want to be able to map them directly to attributes on the class: name and colour respectively.

The question is: how?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 4:20 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
With hibernate 2 this is not possible.

I know about the following options:

- If you have a DB which supports instead of triggers you could create a view and let the triggers handle the insert and update correctly.
- Do the the mapping as the DB dictates. On top of this two mapped classes create a combining Facade which hides the DB desing.
- Have a look at Hibernate 3.

BTW: Option 1 works for non normalized tables as well. Just create 2 views representing the normalized data.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 10:42 am 
Beginner
Beginner

Joined: Tue Jun 22, 2004 7:50 am
Posts: 25
Ah ok. Appreciate the response: sounds like the Facade is the way to go (don't want to migrate to Hibernate3 just yet).

Thanks very much.

Edward


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.