Hi,

I use the merge because the object is modified while detached (client <=>
server/ejb).

-----Ursprüngliche Nachricht-----
Von: Norbert Rieger [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 13. November 2008 14:38
An: [email protected]
Betreff: Setting NULL value on OneToOne mapping

Hi,

how do I "reset" (set foreign key field to NULL) a assocation in a OneToOne
relationship ?

I tried to set it to "null" and then execute merge, but the UPDATE command
does not include this.

e.g.

// ----------------------------
@Entity
class M
{
@Id
long id ;
....
}

// ----------------------------
@Entity
class P
{
@Id
long id ;
int x;
int y;
@OneToOne // optional should be true by default
M myM ;

public void setMyM (M theM)
{ myM = theM ; }

}

....
P p = em.find (....)
p.setX ();
p.setY ();
// release association
p.setMyM ((M)null) ;
em.merge(p) ;

X,Y are updated, but field P.M_ID (foreign key field P=>M) stays unchanged.

How to do this, merge oder by an update command ?

Thanks a lot in advance

NR

Reply via email to