[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] ManyToOne issue
|
Hi,
since 4 month i was able to work with eclipselink w/o any problems,
nice work so far! ;)
But now i got a problem where i need your help :/
I have the following relationship:
[=========>8=========]
class Changes {
@ManyToOne
@JoinColumn(name = "FK_CHANGED_BY")
private User changedBy;
}
class User {
@OneToMany(mappedBy = "changedBy", fetch = FetchType.EAGER)
private List<Changes> changes = new ArrayList<Changes>();
}
// first try:
change.setChangedBy(user);
em.persist(change);
// another try:
user.addChange(change); // does also: change.addUser(this);
em.persist(change);
[=========8<=========]
Regardless of which way i try to set the User to the Changes object or
add the Changes to the User object I always got a "ORA-00001: Unique
Constraint (...) violation". It seems eclipselink tries to insert a
new entry in the users table while updating/saving. How can i get rid
of them and instead just set the FK_CHANGED_BY field with the id of
the user (which always already exists!)?
Thanks in advance!
-- Christian