Step by step Mybatis-Programming Using interface operations (2)

Source: Internet
Author: User

In the previous chapter, we have set up the simplest HelloWorld environment that can be run. This chapter will change the operation method in the previous chapter to operation by interface.

We can find that in the previous chapter

TestBasicQuery (= (Visitor) session. selectOne ("david. mybatis. demo. IVisitorOperation. basicQuery"
 

In this way, in the real development process, if the names on both sides are not properly matched, an exception will occur. In order to avoid this situation, we can use the interface to perform corresponding operations. Next we will modify this section.

First, we create an IVisitOperation class under the package name david. mybatis. demo, which indicates the interface for all methods of the database to be operated in the future, as shown below:

Visitor basicQuery (
TestBasicQueryByInterfaceWay (= session. getMapper (IVisitorOperation. =

In this way, we will not have to worry about the mismatch caused by manually writing method names.

In the next chapter, we will continue to describe the CRUD operations based on a single table. I will sort out the updates as soon as possible ~ ^ 0 ^

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.