Mybatis-session-sqlsession

Source: Internet
Author: User

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.

    • 1. Statement execution

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.