-->
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: 2 classes with One-2-Many relation mapped to a single table
PostPosted: Mon Sep 04, 2006 12:36 pm 
Newbie

Joined: Mon Sep 04, 2006 12:15 pm
Posts: 1
Hi,

Based on my functional requirements, I have modeled two classes A nd B with a one-to-many relation from class A to class B. Ideally, I would prefer to have two tables A_TBL and B_TBL with a FK constraint to hold the data for classes A and B respectively. But our DB model holds the data for both classes in a single table AB_TBL. One record in AB_TBL can hold data for one A object and 10 B objects. DB model was done based on the assumption that A entity will not have more than 10 B entities associated with it.

We dont know the exact reason for why DB was modeled like this? It could be by mistake or intentional denormalization. I myself didn't like it, but we have to live with it.

Is there a way to map directly the attributes of A and B classes to AB_TBL?

One option I have on mind is to introduce a new class AB which would be mapped to AB_TBL. The data from A object and associated B objects would be copied into an AB object and then AB obejct is persisted to DB. The data copying logic would ideally be encapsulated using a DAO class.

But I prefer to do a direct mapping of attributes of A and B classes to AB_TBL if that is possible.

Please let me know.

Thanks in advance for your help,
Balaji.


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.