Wednesday 21 March 2012

Spring support multiple @Transactional datasource

1. Define tx-manager

    <tx:annotation-driven/>
    
        <property name="dataSource" ref="dataSource1"/>
    

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



2. In you service layer code
@Transactional(value = "jdbcTxManager")
public List<String> getNames() {
    return userDao.getNames();
}

@Transactional(value = "jpaTxManager")
public void persitentUser(User user) {
    return user.persist();
}

1 comment:

  1. please have a look
    http://www.rajkrrsingh.blogspot.in/2012/06/spring-working-with-datasource-and.html

    ReplyDelete