Closed GoogleCodeExporter closed 8 years ago
Could you please add your code to the bug? This will ensure that I'm trying to
reproduce the same way.
Thanks.
Original comment by max.r...@gmail.com
on 20 Nov 2009 at 5:33
Here's some example code. I expect that calling storeAFoo() should invoke
jdoPreStore() on both classes, but it only calls Foo.jdoPreStore().
package scratch;
import java.util.Date;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.EmbeddedOnly;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Embedded;
import javax.jdo.listener.StoreCallback;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.JDOHelper;
public class Example {
@PersistenceCapable
@EmbeddedOnly
static class CommonFields implements StoreCallback {
@Persistent
private int version;
@Persistent
private Date dateCommitted;
public void jdoPreStore() {
System.out.println("CommonFields.jdoPreStore called");
version++;
dateCommitted = new Date();
}
}
@PersistenceCapable(identityType = IdentityType.APPLICATION)
static class Foo implements StoreCallback {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Embedded
@Persistent
private CommonFields metadata = new CommonFields();
public void jdoPreStore() {
System.out.println("Foo.jdoPreStore called");
}
}
public static void storeAFoo() {
PersistenceManager pm = PMF.PMF.getPersistenceManager();
try {
pm.makePersistent(new Foo());
} finally {
pm.close();
}
}
public static class PMF {
public static final PersistenceManagerFactory PMF =
JDOHelper.getPersistenceManagerFactory("transactions-optional");
}
}
Original comment by bslesinsky
on 20 Nov 2009 at 10:20
Thanks for the code. I've plugged this into a project that uses the DataNucleus
rdbms plugin and I see the same behavior. DataNucleus core plus the rdbms
plugin is
the reference implementation of JDO, so in cases where the spec doesn't provide
enough guidance I just try to emulate the behavior of the rdbms plugin. Since
app
engine and rdbms are doing the same thing I'm not going to treat this as a bug.
You
might consider filing a bug against the DataNucleus project or even the JDO
spec to
try and get this clarified.
Original comment by max.r...@gmail.com
on 20 Nov 2009 at 11:42
Unfortunately the datanucleus folks have a rather unfriendly-looking issue
tracker and
forum. I did find this, which suggests they know about it and don't seem
particularly
open to requests:
http://www.jpox.org/servlet/forum/viewthread_thread,3574#21014
If you know somebody over there, perhaps you would have better luck.
Original comment by bslesinsky
on 23 Nov 2009 at 10:28
Original issue reported on code.google.com by
bslesinsky
on 20 Nov 2009 at 5:24