JDBCMetadataStore vs transaction manager

109 views Asked by At

As per documentation, JDBCMetadataStore requires an instance of DataSourceTransactionManager and this makes sense. What if I'm using JPA as primary transaction manager in the application? How can I tell to JDBCMetadataStore which transaction manager it should make use when calling the @Transactional methods - assuming I have to have 2 flavours of transaction manager beans in the application. Suggestions are welcome!

1

There are 1 answers

0
Artem Bilan On BEST ANSWER

I suggest you to extend that JdbcMetadataStore and override all the transactional methods with delegation to super and @Transactional with the specific TX manager:

public class MyJdbcMetadataStore extends JdbcMetadataStore {

    public MyJdbcMetadataStore(DataSource dataSource) {
        super(dataSource);
    }

    @Override
    @Transactional("jdbcTransactionManager")
    public String putIfAbsent(String key, String value) {
        return super.putIfAbsent(key, value);
    }

}