The sqlsession instance is the most powerful in MyBatis.
It's where you'll find all of the methods to execute statements, commit or rollback transactions and acquire mapper Insta NCEs.
There is over-methods on the Sqlsession class.
These methdos is used to execute SELECT, INSERT, UPDATE and DELETE statemnets that is defined in your SQL Mapping XML fi Les, there is pretty self expanatory, each takes the ID (defined in <select> in xxxmapper.xml) of the statement and The Parameter Object,which can be a primitive (auto-boxed or wrapper), a JavaBean, a POJO or a Map.
- 2. The difference between SelectOne and selectlist:
SelectOne must return exactly one object or null (none).
If more than one, an exception is thrown.
If you do not know how many objects, use SelectList.
If you like checking the existence of an object, it is best to return a count (0 or 1).
Selectmap is a special case. He was designed to convert a list of results into a Map based on one of the properties in the resulting objects . (not understand).
Because not all statements require parameters, these methods are also overloaded to versions that do not require parameter objects.
Finally, there are three advanced versions of the Select method. They allow you to limit the range of returned rows, or provide custom result handing logic, which is typically used for large data sets.
Mybatis-session-sqlsession