Sqlmapclient interface of the Ibatis framework

Source: Internet
Author: User

Sqlmapclient, which is an important interface in Ibatis, involves the execution and batching of SQL mappings.

Now, let's start by understanding its definition of the start of Query method.

The first is the queryForList method:

Specifies the SQL ID, and the result of the execution returns the list
queryForList (java.lang.String ID);

Specifies the ID of the SQL and specifies the number of rows returned
queryForList (java.lang.String ID, int skip, int max);

Specify the ID of the SQL and specify the incoming parameters
queryForList (java.lang.String ID, java.lang.Object parameterobject);

Specify the ID of the SQL, specify the incoming parameters, and then specify the number of rows returned
queryForList (java.lang.String ID, java.lang.Object parameterobject, int skip, int max);

Next is the queryForMap method:

Executes the SQL ID and takes a field in the result as the map key
queryForMap (java.lang.String ID, java.lang.Object parameterobject, java.lang.String keyprop);

As above, and value in map is the specified field, not the entire returned object
queryForMap (java.lang.String ID, java.lang.Object parameterobject, java.lang.String Keyprop, java.lang.String Valueprop);

Again the queryForObject method:

Executes the specified SQL ID and returns an object that will have an exception sqlexception thrown if there are too many functions queried
queryForObject (java.lang.String ID);

Ibid., plus the parameters passed
queryForObject (java.lang.String ID, java.lang.Object parameterobject);

Ibid, and a reference to the returned object that executes
queryForObject (java.lang.String ID, java.lang.Object parameterobject, Java.lang.Object resultobject);

Finally, it is the Queryforpaginatedlist method, which is the method for paging: But this method has been Deprecated , that is, the use of this method is not supported

The two methods return the Paginatedlist interface.

Specifies the SQL ID of the query and prescribes the number of pages per page
Queryforpaginatedlist (java.lang.String ID, int pageSize);

And with the specified parameters.
Queryforpaginatedlist (java.lang.String ID, java.lang.Object parameterobject, int pageSize);

The last one, that is querywithrowhandler, processes each result of the query:

Specify the SQL ID, specify the parameters, and specify the processor
Querywithrowhandler (java.lang.String ID, java.lang.Object parameterobject, Rowhandler Rowhandler);

Specify the SQL ID, specify the processor
Querywithrowhandler (java.lang.String ID, Rowhandler rowhandler);

Now look at this Rowhandler interface.

This interface has only one definition method:handlerRow(java.lang.Object valueObject)

Therefore, we usually implement this interface, because each processing is our own needs.

The incoming property is the object of each row

Note: This article reproduced: http://njupt.iteye.com/blog/320238

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.