Spring3 to Spring5, ibatis to MyBatis upgrade issues (Help needed!)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Spring3 to Spring5, ibatis to MyBatis upgrade issues (Help needed!)

Stuart Davies

I am upgrading a 10 year old System from Spring 3.2.18 to 5.0.6. This required an upgrade to MyBatis3 Spring:


I have spent some considerable time looking to do this and I have finally! connected to the (Oracle) DB and sent a mapped query. All good so far.

I have to say that I have found very little in the way of information on this process on the web and spent days 'experimenting'.

In the old XML configuration used a SqlMapClientTemplate. I have replaced this with SqlSessionTemplate. The xml below is a snippet from the new config:

<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<property name="url">
<property name="username">
<property name="password">

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
<property name="mapperLocations" value="classpath*:ibatis/SQLMap-MyBatis3.xml"/>
<property name="configurationProperties">
<prop key="maxTransactions">5</prop>
<prop key="maxRequests">15</prop>
<prop key="maxSessions">10</prop>
<prop key="cacheEnabled">false</prop>
<prop key="lazyLoadingEnabled">false</prop>

<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"/>

My current issue is the properties and their equivilent in the new MyBatis configuration data.
I have used http://www.mybatis.org/mybatis-3/configuration.html as a reference for this but there are very few common properties.

I am not really sure if this is the correct place for the configuration of these characteristics or what the equivilent propertry names and values are.

These values were originally taken from a sqlMapConfiguration file thaty looks like this:

<settings maxTransactions="5" maxRequests="15" maxSessions="10" cacheModelsEnabled="false" enhancementEnabled="false" lazyLoadingEnabled="false"/>
<sqlMap resource="ibatis/SQLMap-MyBatis3.xml" />

I have been unable to re-use this file when creating a SqlSessionFactoryBean.

I also need to know if my use of jndi-lookup is correct:

<jee:jndi-lookup id="servicesDataSource"
expected-type="javax.sql.DataSource" />

<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sessionFactoryBean" />

<bean id="sessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="mapperLocations" value="classpath*:ibatis/SQLMap-MyBatis3.xml"/>
<property name="dataSource" ref="servicesDataSource" />

I could do with some relevent examples and pointers to reference material that is not all annotation based.

Could you please help.


Stuart Davies

You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.