You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-user@db.apache.org by Gang Liu <ga...@yahoo.com> on 2012/05/26 02:25:32 UTC

OR mapping for JDO2.0

Hi,

I have 2 use cases and hope someone can give some ideas:

#1 how to write mapping file if a member variable in a class is List<List<String>>
#2. how to write mapping file if a member variable in a class is Map<List<List<String>>,String>

thanks

Tim

Re: OR mapping for JDO2.0

Posted by Gang Liu <ga...@yahoo.com>.
Matthew

Thank you very much

Will try

Tim

Sent from my iPhone

On May 26, 2012, at 5:51 AM, Matthew Adams <ma...@matthewadams.me> wrote:

> JDO doesn't support collections of collections, maps of collections,
> etc.  An easy workaround is to define a class that contains a
> List<String>, like this:
> 
> public class StringList {
>  List<String> list;
> 
>  // ctors, List<String> delegate methods, etc
> }
> 
> Then your #1 becomes List<StringList>.  For #2, you could define
> 
> public class StringListList {
>  List<StringList> list;
> 
>  // ctors, List<StringList> delegate methods, etc
> }
> 
> and then use Map<StringListList,String>.
> 
> -matthew
> 
> On Fri, May 25, 2012 at 7:25 PM, Gang Liu <ga...@yahoo.com> wrote:
>> Hi,
>> 
>> I have 2 use cases and hope someone can give some ideas:
>> 
>> #1 how to write mapping file if a member variable in a class is List<List<String>>
>> #2. how to write mapping file if a member variable in a class is Map<List<List<String>>,String>
>> 
>> thanks
>> 
>> Tim
> 
> 
> 
> -- 
> @matthewadams12
> mailto:matthew@matthewadams.me
> skype:matthewadams12
> yahoo:matthewadams
> aol:matthewadams12
> google-talk:matthewadams12@gmail.com
> msn:matthew@matthewadams.me
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams

Re: OR mapping for JDO2.0

Posted by Matthew Adams <ma...@matthewadams.me>.
JDO doesn't support collections of collections, maps of collections,
etc.  An easy workaround is to define a class that contains a
List<String>, like this:

public class StringList {
  List<String> list;

  // ctors, List<String> delegate methods, etc
}

Then your #1 becomes List<StringList>.  For #2, you could define

public class StringListList {
  List<StringList> list;

  // ctors, List<StringList> delegate methods, etc
}

and then use Map<StringListList,String>.

-matthew

On Fri, May 25, 2012 at 7:25 PM, Gang Liu <ga...@yahoo.com> wrote:
> Hi,
>
> I have 2 use cases and hope someone can give some ideas:
>
> #1 how to write mapping file if a member variable in a class is List<List<String>>
> #2. how to write mapping file if a member variable in a class is Map<List<List<String>>,String>
>
> thanks
>
> Tim



-- 
@matthewadams12
mailto:matthew@matthewadams.me
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12@gmail.com
msn:matthew@matthewadams.me
http://matthewadams.me
http://www.linkedin.com/in/matthewadams