满堂花醉三千客,一剑霜寒十四州。这篇文章主要讲述mybatis-config.xml 和 mapper基本设置相关的知识,希望能为你提供帮助。
mybatis-config.xml :
< ?xml version="1.0" encoding="UTF-8" ?> < !DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> < configuration> < !-- 读取db.properties文件 --> < properties resource="db.properties" /> < !--全局配置参数,需要时再设置 --> < settings> < !-- 开启全局二级缓存 --> < !-- < setting name="cacheEnabled" value="https://www.songbingjia.com/android/true" /> --> < !-- 开启全局延迟加载 --> < setting name="lazyLoadingEnabled" value="https://www.songbingjia.com/android/true"/> < setting name="aggressiveLazyLoading" value="https://www.songbingjia.com/android/false"/> < /settings> < typeAliases> < typeAlias type="com.Mybaits.pojo.ctAniamlPojo" alias="ctAniaml" /> < typeAlias type="com.Mybaits.pojo.animalPojo" alias="Aniaml" /> < typeAlias type="com.Mybaits.pojo.thirdExtendsPojo" alias="ThirdExtends" /> < /typeAliases> < !-- 配置数据源 --> < environments default="development"> < environment id="development"> < !-- 配置事务 --> < transactionManager type="JDBC" /> < !-- 配置连接池 --> < dataSource type="POOLED"> < property name="driver" value="https://www.songbingjia.com/android/${dataSource.driverClass}" /> < property name="url" value="https://www.songbingjia.com/android/${dataSource.jdbcUrl}" /> < property name="username" value="https://www.songbingjia.com/android/${dataSource.user}" /> < property name="password" value="https://www.songbingjia.com/android/${dataSource.password}" /> < /dataSource> < /environment> < /environments> < !-- 映射Sql.xml文件 --> < mappers> < mapper resource="com/Mybaits/mapper/ctAniamlMapper.xml" /> < mapper resource="com/Mybaits/mapper/animalMapper.xml" /> < /mappers> < /configuration>
【mybatis-config.xml 和 mapper基本设置】SQL语句映射mapper:
< ?xml version="1.0" encoding="UTF-8"?> < !DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> < mapper namespace="com.Mybaits.mapper.animalmapperInteger"> < !-- 嵌套查询 --> < resultMap type="Aniaml" id="SelectAnimalResultMap"> < id column="id" property="id" /> < result column="animal" property="animal" /> < association column="Species_id" property="ctAniaml" javaType="ctAniaml" select="com.Mybaits.mapper.ctAnimalmapperInteger.SelectCtAnimalById" /> < /resultMap> < select id="SelectAnimalById" parameterType="int" resultMap="SelectAnimalResultMap"> select *from animal where id=#{id} < /select> < !-- 嵌套结果 --> < resultMap type="Aniaml" id="AniamlResultMapNest"> < id column="an_id" property="id" /> < result column="animal" property="animal" /> < !-- < result column="Species_id" property="speciesid" /> --> < association column="Species_id" property="ctAniaml" javaType="ctAniaml"> < id column="id" property="id" /> < result column="species" property="species" /> < /association> < /resultMap> < select id="SelectContent" resultMap="AniamlResultMapNest"> SELECT a.id , a.Species , b.id as an_id,b.animal FROM cttable a LEFT JOIN animal b ON a.id=b.Species_id ORDER BY a.id < /select> < !-- 扩展结果集 --> < resultMap type="ThirdExtends" id="SelectAnimalExtendsResultMap"> < id column="a_id" property="Extend_id" /> < result column="a_animal" property="animal" /> < result column="b_species" property="species" /> < /resultMap> < select id="SelectAnimalByIdExtends" parameterType="int" resultMap="SelectAnimalExtendsResultMap"> SELECT a.id as a_id, a.animal as a_animal, b.Species as b_species FROM animal a LEFT JOIN cttable b ON a.Species_id=b.id WHERE a.id=#{id}; < /select> < /mapper>
推荐阅读
- create-react-app 搭建的项目中,引入 webpack-bundle-analyzer 打包分析
- android studio打可执行jar包
- ????????????Android????????????(??????)
- vue项目(webpack+mintui),使用hbuilder打包app
- Computer Neworking: A Top-Down Approach
- Android之Dialog
- 优化程序性能(CSAPP:5)
- Appium之xpath定位元素
- Android流量统计