Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Transaction Doesn't Rollback
    primarykey
    data
    text
    <p>We have a Spring Transaction rollback issues, where rollback doesn't seems to be working. <br> Within my service layer method which is annotated with <code>@Transactional</code> I call three different <code>DAOImpl</code> classes to insert 3 records.<br> The middle insert do a get from a 4th table to populate a description field but this get failed. I expect the first insert to rollback but it doesn't seems to be happening. <br> <strong>Few Points:</strong></p> <ol> <li>The 'Get' method throws a Runtime Exception<br></li> <li>We are using <code>org.springframework.jdbc.datasource.DataSourceTransactionManager</code> and <code>MySQL datasource</code> defined in <code>applicationContext.xml</code>. Beans are created in <code>Beans.xml</code> which is imported into <code>ApplicationContext.xml</code> <br/></li> <li>No <code>@Transactional</code> annotation in <code>DAO</code> layer <br></li> <li>We have used <code>&lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;</code> again in <code>applicationContext.xml</code></li> <li>We are using Spring 3.1</li> </ol> <p><strong>UPDATE</strong>:</p> <p>Code snippets....</p> <p>Service Class- This is somthing similar to what I have .... I tested with and without @Autowired. The transaction enable method is called within the service class. </p> <pre> public class CustomerService { //@Autowired CustomerOrderDAO customerOrderDAOImpl; //@Autowired CustomerItemDAO customerItemDAOImpl; //@Autowired CustomerPromotionDAO customerPromotionDAOImpl; //@Autowired PromotionDAO promotionDAOImpl; //other variables public CustomerOrder handleIncomingOrders(CustomerOrder customerOrder) { try { saveOrderDetails(customerOrder); ..... return customerOrder; } catch (Exception e) //TO-DO catch proper exception { //Send error response ....... return customerOrder; } } @Transactional public void saveOrderDetails(CustomerOrder customerOrder) throws Exception { customerOrderDAOImpl.create(customerOrder); .... while (promotionsIterator.hasNext()) { customerPromotion.setPromotionName(promotionDAOImpl.getName(customerOrder.getPromotionId)); customerPromotionDAOImpl.create(customerPromotion); } ...... while (customerItemIterator.hasNext()) { customerItemDAOImpl.create(customerItem); } } } </pre> <p>Any idea? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload