Consider the following JPA entities/embeddables:
@Entity
public class EntityA {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String id;
@Version
private Integer version;
@Embedded
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
private List<EmbeddableB> bs = new ArrayList<EmbeddableB>();
public List<EmbeddableB> getBs() {
return bs;
}
public void setBs(List<EmbeddableB> bs) {
this.bs = bs;
}
}
@Embeddable
public class EmbeddableB {
@Basic
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
private int a;
@Basic
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
private String b;
@Basic
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
List<String> cs = new ArrayList<String>();
@Embedded
@Extension(vendorName = "datanucleus", key = "gae.unindexed", value = "true")
EmbeddableC c = new EmbeddableC();
public EmbeddableB(int a, String b) {
this.a = a;
this.b = b;
cs.add("x");
}
}
@Embeddable
public class EmbeddableC {
@Basic
private List<Integer> z = Arrays.asList(1, 2, 3);
}
The entity A contains a list of embeddables Bs that contain an embeddable C
which contains a list.
Now run this code:
EntityManager em = EMF.get().createEntityManager();
try {
EntityA a = new EntityA();
a.getBs().add(new EmbeddableB(1, "Hello"));
a.getBs().add(new EmbeddableB(2, "World"));
em.persist(a);
} finally {
em.close();
}
We are adding too Bs to an A so that A should contain two lists z coming from
the embedded grandchild C. However, the datastore viewer shows columns a.0,
b.0, a.1, b.1 as expected but only one column z (and not two columns z.0, z.1).
This looks like an error.
(Further, I have to annotate each property of the embedded classes to have them
unindexed. It doesn't suffice to add this annotation just to the property "bs"
of EntityA. This makes not generating indexes rather tedious. But it is
important as soon as the number of generated columns becomes large — and
indexing these columns may even make no sense in the first place.)
Original issue reported on code.google.com by marc.nieper@gmail.com on 17 Apr 2013 at 8:08
Original issue reported on code.google.com by
marc.nieper@gmail.com
on 17 Apr 2013 at 8:08