public <T> T execute(Command<T> command) {
Persister<StatefulSession> persister =
new MemoryPersister<StatefulSession>(new StatefulSessionSnapshotter(getSession()));
persister.save();
Transaction transaction = persister.getTransaction();
try {
transaction.start();
T result = super.executeNext(command);
transaction.commit();
return result;
} catch (Throwable t) {
try {
transaction.rollback();
throw new RuntimeException("Could not execute command", t);
} catch (XAException e) {
throw new RuntimeException("Could not rollback transaction", e);
}
}