From: Kal A. <ka...@te...> - 2004-05-17 16:46:26
|
On Mon, 2004-05-17 at 17:27, Andy Peel wrote: > > 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. > I think you would need to hack the code a bit to do that. But it should all be localised in the HibernateProviderTransaction class I think. > 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. > I didn't enable that, no. Without having a specific application in mind its always a bit difficult to tell what should be turned on and what should not. I guess that it should be possible for you to just hack the configuration files and go with that - I don't think that any of the code should need to change... Cheers, Kal -- Kal Ahmed <ka...@te...> techquila |