From: Andy P. <an...@il...> - 2004-05-17 16:29:56
|
> There is a way to make more coarse-grained transactions with the > Hibernate backend. The relevant methods are: > TopicMapProvider.isTransactional() which returns true if the backend > supports transactions (currently only the Hibernate backend does). > TopicMapProvider.openTransaction() which starts a new transaction and > returns a org.tm4j.topicmap.ProviderTransaction instance. > TopicMapProvider.getOpenTransaction() which returns a handle to the > current transaction. > and then the methods of org.tm4j.topicmap.ProviderTransaction which you > can use to commit or rollback the transaction. Excellent. Sorry, I'd misread the code, and just assumed that the commit always happened, whereas it actually only commits if the method created the new transaction itself. Cool. > Currently nested transactions are not supported at all, but the > hibernate implementation only starts a new transaction for an API call > if one is not already started, so you should be able to do something > like: > > txn = tm.getProvider().openTransaction(); > // Do some stuff here > txn.commit(); // or txn.rollback() I'd actually like to tell the TopicMapProvider to use a transaction that already exists, so that my existing Hibernate transaction manager can create a transaction for use in a service method that does some other stuff in my app and then does the topic map stuff and then maybe does some other stuff specific to my app. I can't see a way to do that at the moment, but I think it'd be easy to add. The other thing was concurrent modification preventation. I had a quick look through the hbf.xml files and couldn't see a version column so I guess it doesn't do optimistic locking. Thanks Kal, Andy. |