Closed GoogleCodeExporter closed 8 years ago
Actually, it seems that the root cause is that the persistence context appears
to be
cleared on tx.commit(). Feature or bug?
@Test
public void entitiesRemainPersistentUponCommit() {
String sampleId = UUID.randomUUID().toString();
// In the first unit of work, we persist an entity to the
// data store with a string id
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Sample sample = new Sample();
sample.setId(sampleId);
sample.setName("FOO");
em.persist(sample);
em.getTransaction().commit();
assertTrue(em.contains(sample));
em.close();
}
Original comment by akbertram
on 10 Apr 2010 at 8:58
Feature, since in the ancient version of datanucleus being used by GAE/J you
have to
make use of the persistence properties "detachAllOnCommit" and "detachOnClose"
to
simulate transactional persistence context. When they update their plugin to
use a
version of DataNucleus that is semi-recent, then that won't be necessary.
Hence not an issue
Original comment by googleco...@yahoo.co.uk
on 10 Apr 2010 at 2:55
Ok, thanks, setting the parameters works.
For the record, a little frustrated that an implementation of a java standard
should
have a "quirks mode"
Here's the code that makes the tests above pass:
public static class EMF {
private static final EntityManagerFactory emfInstance =
Persistence.createEntityManagerFactory("transactions-optional", new HashMap()
{{
put("datanucleus.DetachOnClose", true);
put("datanucleus.DetachAllOnCommit", false);
}});
private EMF() {}
public static EntityManagerFactory get() {
return emfInstance;
}
}
Original comment by akbertram
on 10 Apr 2010 at 8:04
No idea what is a "quirks mode". DataNucleus AccessPlatform passes the JPA1
TCK, and
provides *all* functionality defined in that spec (and the spec is notoriously
glib
on various points).
If their TCK doesn't have any explicit tests for that functionality then blame
then,
not the people who took the time to implement and pass their test. "They" (JPA
Expert
Group - SUN, Oracle etc) developed the TCK in private and you have to sign
NDA's just
to see it never mind identify areas where there are no tests.
Original comment by googleco...@yahoo.co.uk
on 12 Apr 2010 at 9:29
Sorry Andy, no offense intended. Quirks mode is a reference to the HTML
specification
and its implementation.
In any case, this issue can be closed as there is an acceptable workaround and
is not
specific to the appengine plugin in any case.
Thanks
Original comment by akbertram
on 12 Apr 2010 at 12:28
Refer to Issue 103 for use of these flags by default
Original comment by googleco...@yahoo.co.uk
on 27 Jun 2011 at 11:16
Original issue reported on code.google.com by
akbertram
on 10 Apr 2010 at 8:45