review:
1. 多参数查询(@Param,对象)
2. 获取保存主键( select last_insert_id )
3. 动态SQL( if, choose when otherwise, where,set ,trim,foreach )
4. 多表操作(一对一,一对多)
- Nested queries (focus)
nested query: multiple table joins query SQL statement, split into multiple queries (single-table queries)
1.1 one
case: the user query belongs to all accounts and each account
1.1.1 distinguish the operating body
operating body: accounts
1.1.2 to complete multiple queries
SQL statement
1.1.3 mapping configuration file
to configure the mapping file operations on the main body of
1.2-to-many
case: query all accounts in all users, and each user
1.2.1 distinguish the operating body
operating body: user
1.2.2 multiple queries
1.2.3 mapping configuration file
- Loading strategy
loading strategy: query time associated with the query object
is loaded immediately: after the query object, instantly check the associated object (the default configuration)
delay loading (lazy loading): associated objects, when to use, when to check
2.1 local configuration
配置到SQL映射文件的关联关系配置上 (association, collection)
fetchType:
eager
lazy
2.2 Global disposed
in the core configuration file is loaded globally switch
develop methodologies trigger delay loading of
the principles of 2.3 Internal
internal principle: based on dynamic proxy subclass (generated dynamic proxy object is a subclass of the proxy object)
l is proxy object can not be used final modification
3. caching mechanism
3.1 cache
cache:.. SqlSession level cache with the creation of SqlSession created, with the closure and destruction procedures SqlSession comes, can not uninstall
3.1.1 verify cache
3.2 secondary cache
secondary cache:. SqlSessionFactory level cache (cache level Mapper)
3.2.1 secondary cache configuration
- Interface objects need to implement serialization
- Global open second-level cache support
. - Declared in the mapping file you want to use secondary cache
- Saving data to the secondary cache, you are required to submit or close sqlSession
- Core Configuration (focus)
Configuration Item core configuration file: sqlMapConfig
4.1 the Properties
in the core configuration file using an external properties profile
4.2 typeAlias
typeAlias: Set an alias is
4.3 Mappers
loaded sql mapping files
4.4 Settings
Global Configuration
4.5 Rights to
4.6 using self defined database connection pool
4.6.1 coordinate
4.6.2 custom factory
4.6.3
5. programming annotation
action: replacing the SQL mapping file xml
5.1 rule
1. 注解配置到dao接口的方法上
2. 注解中配置sql语句,sql语句的语法和xml映射文件中的语法一致
3. 注解 (@Insert, @Update,@Delete,@Select)
5.2 General Notes (Key)
5.2.1 build environment
package name added to a whole class name dao interface mappers in the core configuration file or set dao interfaces in the form of a package
5.2.2
5.3 mapping relationship
@Results : 声明映射关系配置
id : 当前映射配置的唯一标识
value : 接收@Result数组
@Result :
配置属性和字段的映射关系
property
column
id : boolean参数,表明是否配置主键映射关系(true|false)
默认值:false
@ResultMap : 引用其他已经存在的映射关系配置
value=其他Results中id
Result and Results
resultMap
5.4 multi-table notes (understand)
only supports nested queries
5.4.1 one-
5.4.2-many
interview questions
- Delayed loading strategy
- Caching
operations:
1. Exercise 2 preview the first day of spring.