I have a Spring application in GoogleApp engine which uses JDO to persists objects. So I'm using it in this way in my service layer to keep transactions (with @Transactional annotation).
@Transactional
public void save(Object object) {
dao1.save(object); // dao1 saves using JDO
Object object2 = generate1Object(object)
dao2.save(object2); // dao2 saves using low level API
Object object3 = generate2Object(object)
dao3.save(object3); // dao3 saves using JDO
}
The problem I have is that I need to use the low level API to persist the object2 (because it's an advanced save which cannot be done with JDO). The problem I have is that I don't know how to keep they all in the same transaction. If the dao3 fails when saving the sving done in the love level is not rolledback.
So in the dao2 I persist in this way:
//save using low-level API
public void save(Object object){
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity entity = generateEntity(object);
datastore.put(entity);
}
and in the dao1 and dao3 (the ones which use JDO) I have something like this:
//save using JDO
public void save(Object object) {
PersistenceManager pm = PMF.get().getPersistenceManager();
pm.makePersistent(object);
}
I've seen that the datastore object has a method called:
datastore.getCurrentTransaction()
but it is null for me. How can I make the low level to be aware of the transaction of JDO and keep the three daos in the same transaction.
Thanks.
just use jdo as normal and get hold of the bigtable connection
at least that is the theory, assuming GAE/J implements it