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

Johan Andersson <[email protected]> Mon, 18 Feb 2008 12:24:18 +0100
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
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.

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