Figured it out, the solution is straightforward  see  link for Camel MyBatis
<http://camel.apache.org/mybatis.html>   and  MyBatis-Spring
<https://mybatis.github.io/spring/factorybean.html>    . 
Convert the Spring config to Java and you have it. Below is what I did and
it worked fine.

Add *mybatis-spring* maven dependency

*------------------Sample setup--------------------*

SimpleRegistry registry = new SimpleRegistry();
*ComboPooledDataSource cpds = new ComboPooledDataSource();*
cpds.setDriverClass("oracle.jdbc.driver.OracleDriver");
cpds.setJdbcUrl("jdbc_url");
cpds.setUser("username");
cpds.setPassword("password");
                        
*TransactionAwareDataSourceProxy transactionAwareDataSourceProxy = new
TransactionAwareDataSourceProxy(cpds);*
*DataSourceTransactionManager transactionManager = new
DataSourceTransactionManager(transactionAwareDataSourceProxy);*
registry.put("transactionManager",transactionManager);
ApplicationContext appContext = new ClassPathXmlApplicationContext();
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
                
factoryBean.setConfigLocation(appContext.getResource("mapper/your_mybatis_config.xml"));
factoryBean.setDataSource(cpds);

*SpringTransactionPolicy  propagationRequired = new
SpringTransactionPolicy();*
propagationRequired.setTransactionManager(transactionManager);
propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED",propagationRequired);
                        
*SpringTransactionPolicy  propagationRequiredNew= new
SpringTransactionPolicy();*
propagationRequiredNew.setTransactionManager(transactionManager);
propagationRequiredNew.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW");
registry.put("PROPAGATION_REQUIRES_NEW",propagationRequiredNew);

 camelContext = new DefaultCamelContext(registry);
camelContext.setTracing(true);
camelContext.start();

* MyBatisComponent component = new MyBatisComponent();*
component.setSqlSessionFactory(factoryBean.getObject());
camelContext.addComponent("mybatis", component);
 camelContext.addRoutes(new SomeRoute());
                        



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Mybatis-2-13-1-multiple-statementTypes-in-a-batch-or-Transaction-tp5755122p5755404.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to