What version of OpenJPA are you using and how are you enhancing your entities?
Also, is there are particular reason that you have the @ManagedInterface annotation on your IInterface interface? Unless you plan on using some of the documented managed interface[1] support, *I think* you can safely remove that. Thanks, Rick [1] http://openjpa.apache.org/builds/latest/docs/docbook/manual.html#ref_guide_pc_interfaces On Wed, Apr 25, 2012 at 5:20 AM, CarpathianAnonymous < andreibratu2...@yahoo.com> wrote: > I have an Interface (IInterface) and 2 classes that implements that > interface > (IInterface). Also in another class ( Holder ) I have a collection of > interface items ( Collection<IInterface> ). > > When I try to execute the code from OpenJPA_Test.main, in my associated > table ( holder_classes), the column which is supposed to hold the > references > to Class1 or Class2 objects are NULL. > > public class OpenJPA_Test { > > private static HolderDao holderDao = > EntityDaoFactory.inst().getHolderDao(); > > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > // TODO code application logic here > Holder h = new Holder(); > LinkedList<IInterface> list = new LinkedList<IInterface>(); > > Class1 c1 = new Class1(); > Class2 c2 = new Class2(); > > list.add(c1); > list.add(c2); > > h.setClasses(list); > holderDao.create(h); > > } > } > > > @ManagedInterface > public interface IInterface { > @Id > @GeneratedValue(strategy = GenerationType.IDENTITY) > int getId(); > void setId(int id); > } > > > @Entity > @Table(name = "class1") > public class Class1 implements IInterface { > > @Id > private int id; > @Basic > private int number; > > public Class1() { > } > > @Override > public int getId() { > return id; > } > > @Override > public void setId(int id) { > this.id = id; > } > > public int getNumber() { > return number; > } > > public void setNumber(int number) { > this.number = number; > } > } > > > > @Entity > @Table(name = "class2") > public class Class2 implements IInterface { > > @Id > private int id; > @Basic > private String text; > > public Class2(){ > } > > public String getText() { > return text; > } > > public void setText(String text) { > this.text = text; > } > > public int getId() { > return id; > } > > public void setId(int id) { > this.id = id; > } > } > > > > @Entity > @Table(name = "holder") > public class Holder { > > @Id > @GeneratedValue(strategy = GenerationType.IDENTITY) > private int id; > @OneToMany(cascade = CascadeType.ALL) > private Collection<IInterface> classes; > > public Holder(){ > } > > public Collection<IInterface> getClasses() { > return classes; > } > > public void setClasses(Collection<IInterface> classes) { > this.classes = classes; > } > > public int getId() { > return id; > } > > public void setId(int id) { > this.id = id; > } > } > -- *Rick Curtis*