Hi all,

 

I have the following Problem:

 

I want a function to rollback everything when the database-part passes, but
the email-sending throws an error.

 

Now this is how I tried:

 

applicationContext @ Spring:

 

<bean id="sessionFactory"

 
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactor
yBean">

            <property name="dataSource" ref="dataSource" />

            <property name="configLocation">

                  <value>classpath:hibernate.cfg.xml</value>

            </property>

      </bean>

      <bean id="transactionManager"

 
class="org.springframework.orm.hibernate3.HibernateTransactionManager">

            <property name="sessionFactory" ref="sessionFactory" />

      </bean>

      <tx:annotation-driven />

 

A class injected into a component with Spring which should be transactional
as a whole:

 

@Transactional

      @Override

      public void createUser(Users user, String validateURL) throws
Exception {

            //TODO: geworbenDurch-User finden und Punkte geben.

            

            //EMail versenden

            MimeMessage message = mailSender.createMimeMessage();

            MimeMessageHelper helper = new MimeMessageHelper(message);

            //do stuff

            mailSender.send(message);

            

            

            // Persistent machen

            usersDao.saveOrUpdate(user);

            //usersDao.flush();

            

            

            throw new Exception("xxx");

      }

 

(method of a Spring-loaded class)

 

Now when everything passed and only my Exception(xxx) is thrown no Rollback
is done???

How can I manage this? I should not use .beginTransaction afaik, not to
disturb the annotation-driven transaction-manager?

 

Can anyone help me out?

 

Regards

Markus

Reply via email to