You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Laurie Harper <zo...@holoweb.net> on 2004/03/10 03:18:44 UTC

Mapping composite collections

I'm a bit at a loss on this one :-) I have a class whose properties are 
collections of entries defined by an inner class. I can see how to map 
the inner class onto a database table directly, but not how to either 
map or populate the outer class.

Here's a trimmed down sample of the code I have:

public class Results {
     public class Entry {
         private Race race;
         private Driver driver;
         private short result_type; // race or practice
         private int position;
         private long time;
     }
     private List<Entry> practiceResults;
     private List<Entry> raceResults;
}

So, mapping Results.Entry would be no problem but how do I map Results 
itself? I'd rather be able to materialise an instance of Results 
directly, rather than have to do a pair of collection queries on 
Results.Entry and build a Results instance from them...

Am I stuck with mapping Results.Entry and managing Results instances 
manually or does OJB have a way to do this for me?

Thanks for any suggestions!

L.



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Mapping composite collections

Posted by Laurie Harper <zo...@holoweb.net>.
Heh, I must have been asleep when I wrote that, it all seems so obvious 
now! :-) Sorry for the noise!

L.

Laurie Harper wrote:
> I'm a bit at a loss on this one :-) I have a class whose properties are 
> collections of entries defined by an inner class. I can see how to map 
> the inner class onto a database table directly, but not how to either 
> map or populate the outer class.
> 
> Here's a trimmed down sample of the code I have:
> 
> public class Results {
>     public class Entry {
>         private Race race;
>         private Driver driver;
>         private short result_type; // race or practice
>         private int position;
>         private long time;
>     }
>     private List<Entry> practiceResults;
>     private List<Entry> raceResults;
> }
> 
> So, mapping Results.Entry would be no problem but how do I map Results 
> itself? I'd rather be able to materialise an instance of Results 
> directly, rather than have to do a pair of collection queries on 
> Results.Entry and build a Results instance from them...
> 
> Am I stuck with mapping Results.Entry and managing Results instances 
> manually or does OJB have a way to do this for me?
> 
> Thanks for any suggestions!
> 
> L.



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org