Section Mapper Proxy development model

A: The original development dao

  The actual development, we need programmers to write dao dao interfaces and implementation class.

  1.1 dao Interface

 1.2 dao implementation class

  1.3 test class

  to sum up:

    In the process there is a big lot of repeated dao interface class method, this will increase the amount of code programmers

   Call sqlsession when the method statement of id hardcoded the  example, I find the user based on the user's id  

    When you call a method to change search calls SqlSession additions and deletions, due to the use of the generic type variable method , which at compile time, even if a similar error, no error will not conducive to the development and maintenance

Two: mapper agent development ----> equivalent of a dao interfaces (in fact, has always been one interface ...)

    2.1.1 idea (to follow mapper agent development specification)

Programmers also need to write mapper.xml mapping file

Programmers write mapper interfaces need to follow some development standards, the mybatis can automatically generate mapper interface proxy object class.

 

Development specifications:

    2.1.1.1 mapping file

namespace ---> interface address corresponding to UserMapper

 

  2.1.1.2 UserMapper interface

  2.1.1.2 Test class

  

Guess you like

Origin www.cnblogs.com/Yzengxin/p/11403283.html