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 ?
A sample of Integration with MyBatis is presented in the documentation: https://doc.cuba-platform.com/manual-6.8/myBatis.html
As one possible solution, you can bind the query results to a table using custom datasource as were done here: https://doc.cuba-platform.com/manual-6.8/datasource_custom_class.html. Use ValueCollectionDatasource to map data from several DB tables.
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 . )
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
- create a view in the database
- import the view as a separate entity. Use Generate model wizard in Studio.