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 ^