Hi to all;
This will be a newbie question, I have a collection mapped like the following:
Code:
class A {
....
@OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, mappedBy="a")
@OrderBy("id")
List<B> listOfBs = new ArrayList<B>();
void addB(B b) {
b.setA(this);
listOfBs.add(b);
}
...
}
class B {
...
A a;
String name;
B(name) {this.name=name;}
...
}
A newA = new A();
a.addB(new B("1"));
a.addB(new B("2"));
a.addB(new B("3"));
a.addB(new B("4"));
The question is in what order the B instances are saved, is it guaranteed to have the firstly added B to be persisted first? What if CollectionOfElements is used, is OrderBy annotation enough to guarantee the addition order, or do I have to use IndexColumn annotation and list semantics?