-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping question of an old poor model
PostPosted: Mon Feb 11, 2008 4:08 pm 
Beginner
Beginner

Joined: Wed Dec 03, 2003 2:43 pm
Posts: 22
I have a very poorly modeled table which has the following columns:

string_a
string_b

and

string_c

string_a, string_b are the composite key to this table. There can be many string_c objects for one string_a + string_b key. I would like to be able to load the objects in this table into one objects for a given key with the properties:

stringA - String mapped to the string_a column
stringB - String mapped to the string_b column

stringCs - Collection mapped to the string_c column

For example, if I had the rows:

string_a = 'A'
string_b = 'B'
string_c = 'C'

and

string_a = 'A'
string_b = 'B'
string_c = 'D'

and

string_a = 'A'
string_b = 'B'
string_c = 'E'

loading by the composite_id key or selecting all the rows in the table would produce one object from these three rows of the form:

stringA = 'A'
stringB = 'B'

stringCs = Collection containing "C", "D", "E"

I know this is possible in IBatis. Is there a way to do it in Hibernate as well? (Without using any other table, because unfortunately there is no key table)


Top
 Profile  
 
 Post subject: Re: Mapping question of an old poor model
PostPosted: Mon Feb 11, 2008 8:25 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
You might have to define a collection with a sql-loader for the collection. You would also have to write the relevant update and insert scripts.



Farzad-


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