-->
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: mapping inheritance and 1-many mappings from denormalized DB
PostPosted: Mon Sep 12, 2005 2:16 pm 
Newbie

Joined: Mon Sep 12, 2005 2:00 pm
Posts: 4
Hibernate version:
V3

Name and version of the database you are using:
IBM DB2 v7

We are encountering trouble mapping a mildly denormalized database. By "mildly" I mean there is no duplicated data but tables are combined to reduce the number of queries. I have seen similar denormalization at a few companies so we can't be alone in having to deal with it. I don't see the questions in the discussion list or FAQ.

1. Class A 1 -1 with an optional class B where class B is an inheritance tree. The database represents both classes as columns in the same table. A simplified definition would be:

create table AB
(
A1 INTEGER, --- key
A2 char(50),
BDISCRIMINATOR char(1),
B2 char(30),
B3 INTEGER
)

In other parts of the system where we have the inheritance mapped to its own table and Hibernate works great. Obviously Hibernate is built to handle the mapping when the B classes are in their own table, but is there a way to map this table to our classes?

2. Class C is 1-many (actually up to 5) with class D. Any Java Collection is workable for us. Not my preference, but the DBA wants to avoid another query. The simplified table looks like:

create table CDDDDD
(
C1 INTEGER, --- key
C2 DATE,
C3 char(30),
DDESC1 char(30),
DAPPLIES1 char(1),
DAMOUNT1 FLOAT,
DFREQUENCY1 INTEGER,
.....
DDESC5 char(30),
DAPPLIES5 char(1),
DAMOUNT5 FLOAT,
DFREQUENCY5 INTEGER
)

Again, with two tables Hibernate would handle this fine. We considered maintaining a list for our purposes and creating 20+ field accessors that would present a flat version of the java model purely for Hibernate's usage. Is there a clean way to handle this?

Thanks


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.