Apache JDO Project - Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru

This is Interesting: Free IT Magazines  
Home > Archive > Apache JDO Project > August 2007 > Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: 2.1 Spec: detached-dirty parameters to makePersistent() when DetachAllOnCommit=tru
cbeams

2007-08-06, 1:11 am

My previous email on this topic was a bit verbose, and I later
realized contained some inaccuracies. Keeping things as succinct as
possible, is there any reason the spec couldn't be amended to support
the following code?


package com.xyz;

import org.apache.log4j.Logger;

import javax.jdo.*;
import static javax.jdo.JDOHelper.*;


public class Main {
public static final Logger logger = Logger.getLogger(Main.class);

public static void main(String... args) {
PersistenceManagerFactory pmf =
JDOHelper.getPersistenceManagerFactory("jpox.properties");
PersistenceManager pm = pmf.getPersistenceManager();

assert pm.getDetachAllOnCommit() == true;

A parameter = new A();
A returned;

logger.info("making newly created parameter instance
persistent");
pm.currentTransaction().begin();
returned = pm.makePersistent(parameter);
pm.currentTransaction().commit();

assert parameter == returned;
assert isDetached(parameter) && !isDirty(parameter);

logger.info("dirtying parameter instance");
parameter.setName("mud");
assert isDetached(parameter) && isDirty(parameter);

logger.info("reattaching dirtied parameter instance");
pm.currentTransaction().begin();
returned = pm.makePersistent(parameter);
pm.currentTransaction().commit();

// these assertions currently fail
assert parameter == returned;
assert isDetached(parameter) && !isDirty(parameter);
}
}


@javax.jdo.annotations.PersistenceCapable(detachable = "true")
class A {
private String name;
public void setName(String name) { this.name = name; }
}


Thanks,

- Chris Beams




Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com