Re: Mapping a List<Integer> (or Set<Integer>) with OJB.

Armin Waibel <[email protected]> Wed, 20 Feb 2008 14:46:42 +0100
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi Johan,

Johan Andersson wrote:
> Greetings!
> 
> Say I have a class MyClass it looks like this:
> 
> public class MyClass {
>    private int id;
>    private String name;     private List<Integer> myIntegers = new 
> ArrayList<Integer>;
> 
>    /* getters and setters omitted ... */
> }
> 
> 
> What options do I have if I want to persist this class using OJB?
> 
> The List<Integer> is causing me problems since it is not a pesistent 
> entity class.
> Requirements impede me from just putting it into one field and use a 
> IntList2VarcharFieldConversion.
> Requrements want me to have the List<Integer> data in a separate 
> database table.
> But I just cant figure out how to map this.

Sorry, to have the List<Integer> data in a separate database table is
not supported by OJB. In this case OJB expect a persistence capable
class e.g. Items.

regards,
Armin

> 
> Here's my tables (I am using MySQL):
> CREATE TABLE `MY_CLASS` (
>  `id` int(10) unsigned NOT NULL auto_increment,
>  `name` varchar(255) NOT NULL,
>  PRIMARY KEY  (`id`)
> );
> CREATE TABLE `ITEMS` (
>  `my_class_id` int(10) unsigned NOT NULL,
>  `item_id` int(10) unsigned NOT NULL,
>  PRIMARY KEY (`my_class_id`, `item_id`)
> );
> 
> 
> Thankful for any suggestions.
> /JOHAN
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
>