You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Rick Curtis <cu...@gmail.com> on 2010/08/13 23:39:20 UTC

Embeddable question

I ran across some unexpected behavior pertaining to Embeddables in OpenJPA
that I'm trying to understand. Lets says I have the following domain model:

@Entity
class A{
  @Id
  int id;
  @Embeddable
  Emb emb;
...
}

@Embeddable
class Emb{
....
}

Now suppose the following scenario:

a = new A();
em.persist(a);
em.commit();
em.close();

// At this point a.emb is null.

em  = emf.createEntityManagerFactory();
a = em.find(A.class,a.id)

// WHAT??? Now a.emb != null

// Note: If the previous em.find(...) would have loaded from the DataCache
a.emf is null.

So here is the question, how should this work? I understand that when we
read Entity A from the DB, we don't know if the embeddable should be a null
reference or it should be an Embeddable with no data. The spec doesn't
really detail how it should work, but I would like to have a consistent
behavior. Thoughts, opinions?

Thanks,
Rick