Hello,
I've got a problem with an association one-to-many bidirectional, Lists and save operations.
I have a typical relation
Parent/Child, and I want that this relational will be bidirectional.
I want that the childs have order.
My class Parent is:
Code:
public class Parent{
..........
List<Child> childs = new ArrayList<Child>();
....
//get and set for childs
}
And my Child class is:
Code:
public class Child{
..........
Parent parent;
....
//get and set for parent
}
In my database, I've got two tables: Paretn(PARENT_ID, NAME,.....)
CHILD(CHILD_ID, NAME, PARENT_ID, INDEX_CHILD,......)
Where INDEX_CHILD is the order from the child.
I would like that when I create a new parent and a new childrens, and I save the parent, save the childres too:
Code:
Parent parent = new Parent();
Child child1 = new Child();
parent.addChild(child1);
Child child2 = new Child();
parent.addChild(child1);
Child child3 = new Child();
parent.addChild(child1);
Child child4 = new Child();
parent.addChild(child1);
parent.save();
Is it posible=
Thanks