Integration with MyBatis #2572

Hi

I needed to use sql by connecting MyBatis.
I have updated spring.xml file as recommented (Integration with MyBatis - CUBA Platform. Developer’s Manual) and received an error.
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘cubaDataSource’ of bean class [org.mybatis.spring.SqlSessionFactoryBean]: Bean property ‘cubaDataSource’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243)

Please post the simplest example of a working project (Person = id + name). Using postgreSql with its UUID id.

Hi Alex,
Please replace sqlSessionFactory bean in the spring.xml with following:


<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  <property name="dataSource" ref="cubaDataSource"/>
  <property name="configLocation" value="cuba-mybatis.xml"/>
  <property name="mapperLocations" value="classpath*:com/sample/sales/core/sqlmap/*.xml"/>
</bean>

Bean definition isn’t correct in the documentation. We’ll fix it.

Thanks

Thanks.
Further on the text of the example
SqlSession sqlSession = AppBeans.get(“sqlSession”);
Execption “NoSuchBeanDefinitionException: No bean named “sqlSeccion” available”.
Works
SqlSessionFactory sqlSessionFactory = AppBeans.get(“sqlSessionFactory”);
SqlSession sqlSession = sqlSessionFactory.openSession();
but
order = (Order) sqlSession.selectOne(“com.sample.sales.selectOrder”, orderId);
again gives an error “Error querying database. Cause: org.hsqldb.HsqlException: incompatible data type in conversion” - parameter must be “customerId”.
Do I have to manually close the myBatis session or the Cube itself?
Please post the simplest example of a working project (Person = id + name). Using postgreSql with its UUID id.

Hi Alex,

I have created the sample project (see attachment).
Button “Amount” on the Orders browser screen finds order using MyBatis and shows selected order amount.

Do I have to manually close the MyBatis session or the Cube itself?
MyBatis session will be closed automatically by a transaction commit.

Thanks,
Subbotin Andrey

sales.zip (118.4K)