Hello,
I would like for my mailAbonne method to be fully transactional. I noticed that even on a MailException being thrown the data is persisted by the dao (dao.persistMailingAbonnee(ma);). What's wrong with my configuration?
Can anyone please help?
Thanks in advance,
Julien.
Code:<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="${mail.server}"/> <property name="port" value="${mail.port}"/> </bean>Code:<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean>Code:@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {MailException.class}) private boolean mailAbonne(List<Sculpture> sculpturesChoisiesPourMailing, Abonne abonne) { try { for (Sculpture sculpture : sculpturesChoisiesPourMailing) { MailingAbonnePK mapk = new MailingAbonnePK(sculpture.getSculptureID(), abonne.getAbonneID()); MailingAbonne ma = new MailingAbonne(mapk, new Date()); dao.persistMailingAbonnee(ma); } envoyerMail(sculpturesChoisiesPourMailing, abonne); return true; } catch (MailException e) { log.error("MailException"); log.error(e); return false; } }


Reply With Quote
