20200105-- review all of the first day of learning content mybatis

The next day mybatis
advanced mapping cache (query) with integrated spring

Course Review
What mybatis that? Is a persistence framework, is an incomplete orm framework, sql statement requires the programmer to write
but mybatis there are maps (maps and input and output parameters of the results of the mapping)
mybatis entry threshold is not high, learn low cost, because of his flexibility is good , and let the programmer concentrate on sql statement.

mybatis execution
1) SqlMapConfig configuration file name is not fixed
2) loading configuration file mybatis running environment, creating sqlsessionFactory
actual use, managed by a single manner.
3) created through the factory sqlseesion, oriented user interface (provided database operation method), to achieve the object of the thread is unsafe, it is recommended sqlsession application in vivo
4) calls sqlsession way to operate the database, if the transaction is committed, it is necessary sqlsession.commit ()
5) release of resources

mybatis development dao
. 1) original dao, dao require programmers to write interface and implementation class
2) in the need to inject sqlsessionFactory factory implementation class dao

mybatis mapper proxy
write mapper interfaces only need to program (that is, dao Interface)
programmer writing mapper.xml need to follow the development of norms and mapper.java
1) The mapper.xml the namespace is the full path mapper.java of
2) mapper. the method of statement xml id and is consistent mapper.java
3) consistent with the type of input parameter types and mapper.java parameterType mapper.xml specified input parameters in the statement
4) resutlType specify the output result, the statement mapper.xml method returns the type and value consistent mapper.java

sqlmapconfig file
can be configured properties properties, aliases, mapper loading parameters

Input mapping
parameterType: input type can be a simple type, pojo type, hashmap
for comprehensive inquiries, suggestions pojo use a wrapper class, help system, expansion

Output mapping
resultType: consistent query to specify the column names and attributes of pojo to the successful mapping
resultMap: advanced mapping can be done by resultMap
inconsistent with how the query to the column name and attribute names, attribute names can be listed among the set by resultMap correspondence between

Advanced mapping maps to a column in one pojo property
is mapped to a column associated with the query List<pojo>many
dynamic sql

determining if
WHERE
the foreach
SQL fragments

Today curriculum

Advanced mapping: one-to-many-many query
delay in loading
the cache, cache secondary cache
mybatis integration with spring
reverse engineering

Published 657 original articles · won praise 39 · views 60000 +

Guess you like

Origin blog.csdn.net/qq_36344771/article/details/103840091