Spring 3 problems with TransactionManager and annotations?

To get rollback when an exception is thrown add this.

To get rollback when an exception is thrown add this: @Transactional(rollbackFor=Exception. Class) You will also need to set up the transactionManger bean (here is mine, using hibernate) : I found this tutorial informative.

Thanks for the answer, anyway I'm not using only plain JDBC and I've already configured my TransactionManager (added now the code in the question) – Emanuele Blanco Jul 15 at 9:12 1 @Transactional rollbacks by default on RuntimeExceptions, so you would need the specify the rollbackFor attribute only if you want to rollback on checked exceptions also, or if you need a more fine-grained control (rollback on your custom exceptions, for example). The poster says the method is throwing a RuntimeException. – Nicolae Albu Jul 16 at 16:44.

I believe that @Autowired and @Resource aren't scanned by Spring on a @Component. Try to use a ContextHolder class to get the context and the DAO @Component public class ContextHolder implements ApplicationContextAware { /** * Spring context which will directly be injected by Spring itself */ private static ApplicationContext context = null; /** * Overridden method of ApplicationContextAware, which will automatically be called by the container */ public void setApplicationContext(ApplicationContext context) throws BeansException { this. Context = context; } /** /** * Static method used to get the context */ public static ApplicationContext getApplicationContext() { return context; } } and call your dao with : ContextHolder.

GetApplicationContext(). GetBean("MyDAO").

At least the @Autowired annotation works fine on a class annotated with @Component. I have used it many times. – Nicolae Albu Jul 16 at 16:47.

I solved by using @Transactional(rollbackFor = RuntimeException. Class) and switching from a BasicDataSource to a ComboPooled that's present in c3p0 library. Thanks for the suggestions though.

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