openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbert Rieger" <nrie...@lplusr.de>
Subject AW: Setting NULL value on OneToOne mapping
Date Thu, 13 Nov 2008 14:04:22 GMT
Hi,

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

-----Urspr√ľngliche Nachricht-----
Von: Norbert Rieger [mailto:nrieger@lplusr.de] 
Gesendet: Donnerstag, 13. November 2008 14:38
An: users@openjpa.apache.org
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


Mime
View raw message