-->
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.  [ 6 posts ] 
Author Message
 Post subject: Which map strategy for 2 classes over 1 table
PostPosted: Mon Feb 23, 2004 12:02 pm 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
I whould like to have some suggestions about this situation:
There is a large table, with 60 columns (TABLE_A).
The first 20 columns are always used, while the others are used seldom.
I would like to have 2 classes (LightClass & HeavyClass) to not transfer to client-side all the 60 columns (using LightClass with only the first 20 columns).
Which is the best strategy?
I've tried to create a HeavyClass which inherits from LightClass and I try to use both sub-class and joined-sublclass tab, but both of them are useless, since I do not have different rows for different classes, but the same row can be of one class or another depends on call.
So I've tried to map 20 columns in LightClass and 40 in HeavyClass and map a one-to-one relation between them ... but it do not work for 2 reason:
1) proxy do not work with one-to-one mapping (the second class is always read also if is a proxy) ...
2) and if the 2 tables has the same name there are some exceptions at run-time.

And, ... if possible, I whould not like to have 2 mapping files with 40 columns in common between them.
Thansk for help
Alessandro Rizzi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at http://www.hibernate.org/41.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 12:15 pm 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
gloeglm wrote:

Thanks for your suggestion.
I've seen it, but in this situation I have to copy & paste all the 40 common columns in the mappings. Is there a way to avoid it?
Regards
Alessandro Rizzi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 1:18 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
If you use XDoclet you might want to try something like....

AbstractLightClass
... your 20 common fields go here with XDoclet field mappings

Abstract40LessUsedFieldClass extends AbstractLightClass
... your 40 fields go in here with XDoclet field mappings.

LightClass extends AbstractLightClass
Just map the class/table here all field mappings will be inherited
@hibernate.class table="60ColumnTable"

HeavyClass extends Abstract40LessUsedFieldClass
Just map the class/table here all field mappings will be inherited
@hibernate.class table="60ColumnTable"

hope this helped!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 1:33 pm 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
This could help me, but I do not use XDocLet ... (for many pourpose, not under my control)
Each Hibernate mapping is on a separated file.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 1:43 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 2:14 pm
Posts: 40
Location: Atlanta, GA, USA
That's too bad, it really makes doing your mappings much easier and more intuitive. I'm pretty sure you will have to duplicate your mappings, because even with XDoclet the mapping XML files that are generated would contain duplicated columns. The advantage is that you only have to deal with each column in one place and then let Ant and XDoclet do the dirty work. It would be worth your time (IMO) to discuss this possiblity with whoever is in control. If not I guess you'll just do a simple copy and paste. ;)

good luck!


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