Hi,
I think that I found a Toplink bug or I'm missing something about JPA:
Let classes A and B have an one-to-one required association:
@Entity
public class A {
@Id
@GeneratedValue(strategy=SEQUENCE)
Long id;
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn (nullable=false)
B b;
}
@Entity
public class B {
@Id
Long id;
}
It's impossible for a B object to have the same id value of A object.
The following session bean's method doesn't run:
public void test() {
A a = new A();
B b = new B();
// a.id is null ok
em.persist(a);
// a.id still is null Is this correct?
b.setId(a.getId()); // this will set b.id = null;
}
If I change A's strategy to AUTO the method runs ok. The point is
precisely this: if i change strategy i must change the logic of my code.
Is this correct?
Thanks,
Leandro
--
|:| Prof. Leandro J. Komosinski
|:| Depto de Informática e Estatística
|:| Centro Tecnológico
|:| Universidade Federal de Santa Catarina
|:| -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
|:| leandro_at_inf.ufsc.br
|:| http://www.inf.ufsc.br/~leandro
|:| fone: (48) 3721 7508