I have an unowned relationship in my Domain model
@Entity
public class A {
@Id
private String id;
private Key firstB;
private Key secondB;
// getters & setters
}
@Entity
public class B {
@Id
private Key id;
private String name;
// getter & setter
}
KeyFactory.createKey(B.class.getSimpleName(), name) is the way I generate the Key for class B
I save B independently from A and assign it to an instance of A some time. The problem is that after saving A both fields firstB and firstA are null.
Any idea of what I’m doing wrong?
Keyobjects are not persisted by default so require explicit annotation which is why you are seeingnullvalues.Try annotating
firstBandsecondBas@Enumerated(this should really be@Basicbut there is a bug which prevents this from working):Update: The latest SDK and DataNucleus JARs now correctly allow the use of @Basic.