The code below doesn't run because b don't have id. But, if i change the generated value to AUTO it runs ok. Is it normal ok is it a bug?
Thanks for any help.
Leandro
@Entity
public class A
@Id @GeneratedValue(strategy=GeneratedType.SEQUENCE)
Long id;
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(nullable = false)
B b;
// setters and getters
}
@Entity
public class B {
@Id
Long id;
// setters and getters
}
@Stateless
public class SBean implements SLocal {
public void m() {
A a = new A();
B b = new B();
//1- a don't have id (id is null)
em.persist(a);
//2 - a still don't have id .
a.setB(b);
b.setid(a.getId);
}
[Message sent by forum member 'leandro_komosinski' (leandro_komosinski)]
http://forums.java.net/jive/thread.jspa?messageID=259185