Autocommit and @Transactional and Cascading with spring, jpa and hibernate?

Also, feel free to read the entire chapter on spring transactions.

You can't have queries without an active transaction in hibernate @Transactional has a propagation attribute, which identifies the transaction behaviour when new methods are called. The default is REQUIRED, which is what you want. Here you can find a graphical presentation of the concept.

You can omit using @Transactional if you set-up your transactional methods with aop, like this: That makes all public methods in the service package transactional. Also, feel free to read the entire chapter on spring transactions.

Hmm, ok that would work, seems like the idea I had about using autocommit was a bad idea anyway. I think it would be better practice for me to just annotate the services propertly. Autocommit on any db operation would too easily lead to a broken state.

Instead of doing a blacklist approach I should go with a whitelist (metaphorical). I will try to create an advice that adds @Transactional to all beans annotated with @Service. Though first read about spring-aop.

:) thanks – subes Dec 3 '09 at 11:42 the advice for transactional was a bad idea afterall: -- ibm. Com/developerworks/java/library/… -- stackoverflow. Com/questions/1882959/… -- my solution is to only annotate methods that do write operations and leave the rest not annotated.

Adding propagation=SUPPORTS and readonly=true would maybe increase performance with hibernate, but that is currently too much effort for me to put into an aspectj CTW aspect. – subes Dec 22 '09 at 12:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions