Mybatis integration

Hi.
How to create service with mybatis integration that retrieves list of data from native sql multi table join select query result and bind to table with pager ?

1 Like

Hi,
A sample of Integration with MyBatis is presented in the documentation: Integration with MyBatis - CUBA Platform. Developer’s Manual
As one possible solution, you can bind the query results to a table using custom datasource as were done here: Custom Implementation Classes - CUBA Platform. Developer’s Manual. Use ValueCollectionDatasource to map data from several DB tables.

Hi ,
Thank you for ur repy .

I created custom data source and injected service that implements mybatis . But following exception occured
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value.

I have two question
1 ) can i convert native query result to non entity just custom class
2) how to bind native query result to table with pagination (i dont like orm and jpa just like controll db by native queries . :wink: )

Hi,
I think it is possible to organize pagination by passing limit and offset to the service.
But is not a good approach: CUBA platform provides powerful datasources. Security, pagination, sorting and other useful features are already there.
If you need to map data from several tables you can

  1. create a view in the database
  2. import the view as a separate entity. Use Generate model wizard in Studio.

Regards.