I have method
public PersistenceManagerFactory getPersistenceManagerFactory() for
PersistenceManagerFactory
insted of private static final PersistenceManagerFactory pmfInstance
=
=======
private PersistenceManagerFactory pmf;
public PersistenceManagerFactory getPersistenceManagerFactory() {
if (pmf == null) {
Properties newProperties = new Properties();
newProperties.put("javax.jdo.PersistenceManagerFactoryClass",
"org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory");
newProperties.put("javax.jdo.option.ConnectionURL",
"appengine");
newProperties.put("javax.jdo.option.NontransactionalRead", "true");
newProperties.put("javax.jdo.option.NontransactionalWrite",
"true");
newProperties.put("javax.jdo.option.RetainValues",
"true");
newProperties.put("datanucleus.appengine.autoCreateDatastoreTxns",
"true");
pmf =
JDOHelper.getPersistenceManagerFactory(newProperties);
}
return pmf;
}
this method is write on LocalDatastoreTestCase class
and test class is like
public class JdoSimpleTestCase extends LocalDatastoreTestCase {
public void testSimple() {
PersistenceManagerFactory pmf = getPersistenceManagerFactory();
DataJdo dataJdo = new DataJdo();
dataJdo.setStringVal("tata");
dataJdo.setIntegerVal(1);
PersistenceManager pm = pmf.getPersistenceManager();
try {
System.out.println("Before: " + dataJdo.toString());
pm.makePersistent(dataJdo);
System.out.println("After: " + dataJdo.toString());
} finally {
pm.close();
}
pm = pmf.getPersistenceManager();
dataJdo = (DataJdo) pm.getObjectById(DataJdo.class,
dataJdo.getId
());
System.out.println("Retrive: " + dataJdo.toString());
pm.close();
}
// more tests
}
these suggestions can help
--
Petrica Clement Chiriac (Tica2)
Fluxinternet SRL
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---