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
Hi

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

"org.mybatis:mybatis:3.4.6",
"org.mybatis:mybatis-spring:1.3.2"

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">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@xxxxxxxxxxxxxxxxxxxxx</value>
</property>
<property name="username">
<value>xxxxxxxxxxxxxx</value>
</property>
<property name="password">
<value>xxxxxxxxxxxxxx</value>
</property>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="mapperLocations" value="classpath*:ibatis/SQLMap-MyBatis3.xml"/>
<property name="configurationProperties">
<props>
<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>
</props>
</property>
</bean>

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

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:

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

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"
jndi-name="${jndi.name}"
expected-type="javax.sql.DataSource" />


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

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

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

Could you please help.

Regards

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.