-->
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.  [ 5 posts ] 
Author Message
 Post subject: Split a legacy table into multiple objects.
PostPosted: Thu May 04, 2006 8:11 pm 
Newbie

Joined: Thu May 04, 2006 7:48 pm
Posts: 6
I have a legacy table that I can not break up in the database and am attempting to figure out a way to map the table to different objects with a one-to-many relationship to those objects.

For example:

This table consists of data such as Language1, Language2, Language3...etc upto 15. Right now I am mapping all 15 Language fields to one object along with all the other properties of that object.

public class PersonalInfo
{
...
public string Name {...}
public IList<Address> Addresses {...}
...
public string Language1 {...}
public string Language2 {...}
}

What I would rather do is transform a LegacyLanguage object to a CollectionLanguage object (i.e. IList<Language> Langauges). I have not been able to think of a good way to do this that is sensible and is not TOO dirty. This way the UI developer can repeat the Languages on the UI without having to bind each individual Language.

Please help! I apologize if everything I am saying is very random, but I am truly working on very little sleep. We're on a very short deadline considering we're preparing for hurricane season which is coming up June 1st.

_________________
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 11:11 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You can't map multiple columns to elements in a collection. However, you can map them all separately, and provide a collection or array that is backed by those 15 get/set methods. That would satisfy both hibernate and your API requirements.

I don't know how to write backed collections in whichever .NET language you're using. In java, you'd extend AbstractList, overriding the get, add, remove and size methods (so languageList.get(7) would return internalLanguage7, etc.). Hope that helps.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject: Exactly what I was looking for!
PostPosted: Fri May 05, 2006 9:44 am 
Newbie

Joined: Thu May 04, 2006 7:48 pm
Posts: 6
tenwit wrote:
You can't map multiple columns to elements in a collection. However, you can map them all separately, and provide a collection or array that is backed by those 15 get/set methods. That would satisfy both hibernate and your API requirements.

I don't know how to write backed collections in whichever .NET language you're using. In java, you'd extend AbstractList, overriding the get, add, remove and size methods (so languageList.get(7) would return internalLanguage7, etc.). Hope that helps.


That is _exactly_ what I was looking for. I am blushing a bit as this is way too simple. I think I'm over complicating things from exhaustion.

Thank you VERY much!!

_________________
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 10:03 am 
Newbie

Joined: Thu May 04, 2006 7:48 pm
Posts: 6
Once again, thank you very much!

Here is what I did incase someone else has this same question. Basically I followed your guidelines exactly. I created a private arraylist of language objects. I then created a LegacyLanguages class where each get/set assigns/inserts to the appropriate index of the private arraylist. I created a public get for the arraylist. Now the UI developer can use the LegacyLanguages collection as a legacy object or access the exposed arraylist for the non-legacy class Language.

Thanks again!

_________________
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 6:45 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You're welcome. You could rate my post, that's a more tangible reward :)

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.