Mybatis calls methods of views and stored procedures
The current project takes mybatis as the O / R mapping framework, which is really easy to use and very convenient for project development. Mybatis supports ordinary SQL query, view query and stored procedure call. It is a very excellent persistence layer framework. It can use simple XML or annotation term configuration and original mapping to map the interface and POJO in Java into records in the database.
I Call view
The following is how to call the view to query the revenue details. The SQL part is as follows:
The data type returned by this view is map.
The mapper section is as follows:
The interface part is as follows:
The implementation is as follows:
As shown in the above example, calling the view is like calling a normal SQL query statement.
II Call stored procedure
Calling a stored procedure may also return a result set. Here, I mainly describe the return result set.
(1) Contains the returned result set
For example, the stored procedure structure is as follows:
The SQL part is as follows:
Then the mapper part is:
The interface part is:
(2) No result set returned
The SQL part is as follows:
The above is the method of mybatis calling views and stored procedures introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!