openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Embeddable question
Date Fri, 13 Aug 2010 21:39:20 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message