[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[eclipselink-users] Specification interpretation question
|
- From: Laird Nelson <ljnelson@xxxxxxxxx>
- Date: Mon, 17 Aug 2009 15:36:04 -0400
- Delivered-to: eclipselink-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=BadPyoPX4kXFy2hdCmXB2+vMMdX3nBoUUjirKYCszo4=; b=mnP1/x7b/6KOGlx+n/MSfLWjf/NRi+bEM+VJ87/8+WKqCzx8PHyVQj96xQwVDhmiQg uu0HesZgsfwy+165LXGQ7zyJ2lGvLuFblao401l3uFlMFpCdyyC9dstLPuHzbayQy2k6 WK9b3VmnxMtFpvH4qA3kuFQ0S6Fiqkvh14+cQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=ra7St3zCmtesync2g00iLXsts+axKsHgcsPjBGLDZhuWhDAduM2Hk0JbqC+1t95ZSR 2OqBJqg6tD/mo0gLzlLxFXEGbGJjkBH2273iVE/XfHtjGMfssrC5rwtl804byy0ITgqb +nB4o41dTjdSgmkqdWhETUXJnMapUBMk6/fNo=
Without checking to see what the behavior is, please tell me what you think the behavior should be for the following scenario:
I have an entity E1 that has a primary key field named x:
@Entity(name = "E1")
public class E1 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "x")
private int x;
public int getX() {
return this.x;
}
}
I have an entity E2 like this:
@Entity(name = "E2")
public class E2 implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "e1", referencedColumnName = "x", insertable = false, updatable = false)
private E1 e1;
@Column(name = "e1")
private int e1ID;
public E2() {
super();
}
public int getE1ID() {
return this.e1ID;
}
public void setE1ID(final int code) {
this.e1ID = code;
}
public E1 getE1() {
return this.e1;
}
}
In a container-managed stateless EJB, suppose someone has passed in an E2 whose e1ID field has been set explicitly to a valid e1.x value, as though constructed thusly:
final E2 e2 = new E2();
e2.setE1ID(5); // assuming that in the data store there is an E1 with a primary key of 5
Now, what should be the behavior in this EJB if I do this:
assert e2.getE1ID(5); // i.e. verify the conditions described above
e2 = this.entityManager.merge(e2);
assert e2 != null;
final E1 e1 = e2.getE1(); // XXX what should be the result here? Should e1 be null or not?
I've asked the same problem of the OpenJPA folks and I am curious to hear the EclipseLink team's answer.
Thanks,
Laird