Introduction to mybatis principle and test ox knife
In my opinion, the principle of mybatis is consistent with that of hibernate in some aspects. First, review the principle of Hibernate (the principle is mainly to master and understand the following six objects:
There are six important objects in Hibernate:
Configuration: read the configuration file (mainly hibernate-config.xml) and start hibernate
Sessionfactory: responsible for initializing hibernate
Session interface: responsible for crud operation of persistent objects
Transaction: responsible for the transaction (opensession or getcurrentsession)
Supplementary notes:
The main difference between opensession and getcurrentsession is that each time opensession obtains a new session object, while getcurrentsession obtains a session object bound to the current thread
Query interface and criteria interface: responsible for executing various database queries
What mybatis and Hibernate have in common is to create a session through sqlsessionfactory, so as to achieve the purpose of session operating the database.
Steps of mybatis bull knife test:
1、 Guide Package
2、 Write master profile:
3、 Create entity class
4、 Write Dao
5、 Write mapping file
6、 Write interface
7、 Implementation class of write interface
8、 Run the main method in the implementation class (test)