MyBais中xxMap.xml中的知识点
添加新的mapper的时候下面两个标红的地方要注意,如果统一约定好命名的话都还好,但是就怕一会这样一会那样的业务代码;
总之小心!
<!-- spring与mybatis整合配置,扫描所有dao,指定的映射器类是接口,接口方法可以用注解来指定 SQL 语句,但是 MyBatis 的映射器 XML 文件也可以用。 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="com.cloudwalk.shark.mapper"
p:sqlSessionFactoryBeanName="sqlSessionFactory"/>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/spring/mybatis.xml"/> <property name="typeAliasesPackage" value="com.cloudwalk.shark.model"/> <property name="mapperLocations" value="classpath*:mapper/*.xml"/>
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<!--使用下面的方式配置参数,一行配置一个 -->
<value>
dialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<resultMap id="advertResult" type="cn.bankbrain.advert.inter.service.advert.result.AdvertResult">
<id property="id" column="ID" jdbcType="VARCHAR"></id>
<result property="commercialId" column="COMMERCIAL_ID" jdbcType="VARCHAR"></result>
<result property="planName" column="PLAN_NAME" jdbcType="VARCHAR"></result>
<result property="startDate" column="START_DATE" jdbcType="VARCHAR"></result>
<result property="endDate" column="END_DATE" jdbcType="VARCHAR"></result>
<result property="version" column="VERSION" jdbcType="VARCHAR"></result>
<result property="adStatus" column="AD_STATUS" jdbcType="VARCHAR"></result>
<result property="adType" column="AD_TYPE" jdbcType="VARCHAR"></result>
<result property="merchantName" column="MERCHANT_NAME" jdbcType="VARCHAR"></result>
<result property="isForver" column="IS_FORVER" jdbcType="VARCHAR"></result>
<collection property="advertFileList" ofType="cn.bankbrain.advert.inter.service.advert.result.AdvertFileResult">
<result property="filePath" column="FILE_PATH" jdbcType="VARCHAR"/>
<result property="fileName" column="FILE_NAME" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<sql id="querySql">a.id,a.plan_name ,a.version,
a.start_date ,a.end_date , a.ad_status ,
m.merchant_name ,a.commercial_id,f.file_path,f.file_name,
case when a.start_date is null or a.end_date is null
then 1 else 0 end as is_forver
</sql> <!--查询条件集-->
<sql id="condition_list">
where 1=1
<if test="id != null">AND a.ID = #{id}</if>
<if test="merchantName != null">AND m.MERCHANT_NAME = #{merchantName}</if>
</sql>
<select id="findAdvertByMap" parameterType="java.util.Map" resultMap="advertResult">
select <include refid="querySql"></include>
from cw_pay_advert a join CW_PAY_COMMERCIAL_TENANT m on
a.commercial_id = m.id
left join cw_pay_advert_file f on a.id = f.advert_id
<include refid="condition_list"></include>
</select>
MyBais中xxMap.xml中的知识点的更多相关文章
- SpringMVC项目中web.xml中的节点载入顺序问题
SpringMVC项目中web.xml中的节点载入顺序问题,之前以为web.xml中就是一些配置信息,和节点的顺序没有关系.后来才发现初始化时的载入顺序是和节点的顺序相关的. 完整的web.xml文件 ...
- android中string.xml中%1$s、%1$d等的用法
今天在研究前辈写的代码的时候,突然发现string里面出现了<stringname="item_recent_photo">最近拍摄%1$s</string> ...
- websphere中的会话超时设置 和 web应用中web.xml中session-timeout关系
Tomcat默认的会话的超时时间设置 设置Tomcat session有效期的三种方式有: 1.在tomcat/conf/web.xml中修改session-timeout的值,该设置是TOMCAT全 ...
- 【转】idea中applicationContext-trans.xml中的Cannot resolve bean 'dataSource'...的问题解决
问题如下: (applicationContext-trans.xml中的部分截图) 先了解问题是怎么出现的: 此处的dataSource是在applicationContext-dao.xml中配置 ...
- Mybatis中的XML中需要用到的转义符号整理
使用这么久的Mybatis中需要转义的符号整理一下,小结一下: 1. < 小于符号 < 2. <= 小于等于 ...
- idea中applicationContext-trans.xml中的Cannot resolve bean 'dataSource'...的问题解决
问题如下: (applicationContext-trans.xml中的部分截图) 先了解问题是怎么出现的: 此处的dataSource是在applicationContext-dao.xml中配置 ...
- Servlet容器Tomcat中web.xml中url-pattern的配置详解[附带源码分析]
目录 前言 现象 源码分析 实战例子 总结 参考资料 前言 今天研究了一下tomcat上web.xml配置文件中url-pattern的问题. 这个问题其实毕业前就困扰着我,当时忙于找工作. 找到工作 ...
- Android中string.xml中的的标签xliff:g(转载)
转自:http://blog.csdn.net/xuewater/article/details/25687987 在资源文件中写字符串时,如果这个字符串时动态的,又不确定的值在里面,我们就可以用xl ...
- maven中pom.xml中配置整理: groupId、artifactId、parent、dependency、dependencyManagement区别
<groupId>com.mycompany.commonmaven</groupId> <artifactId>commonmaven</artifactI ...
随机推荐
- Netty 仿QQ聊天室 (实战二)
Netty 聊天器(百万级流量实战二):仿QQ客户端 疯狂创客圈 Java 分布式聊天室[ 亿级流量]实战系列之15 [博客园 总入口 ] 源码IDEA工程获取链接:Java 聊天室 实战 源码 写在 ...
- PostgreSQL Client Authentication Configuration File
PostgreSQL: Documentation: 10: 16.4. Installation Procedure https://www.postgresql.org/docs/10/stati ...
- File syncing and sharing software with file encryption and group sharing, emphasis on reliability and high performance.
http://seafile.com/ showdoc haiwen/seafile: File syncing and sharing software with file encryption a ...
- 记录一次MySQL两千万数据的大表优化解决过程,提供三种解决方案(转)
问题概述 使用阿里云rds for MySQL数据库(就是MySQL5.6版本),有个用户上网记录表6个月的数据量近2000万,保留最近一年的数据量达到4000万,查询速度极慢,日常卡死.严重影响业务 ...
- appium(5)-Appium capabilities
Appium Capabilities Appium server capabilities Capability Description Values automationName Which au ...
- Linux-VMware三种网络模式
虚拟机网络模式 对于VMware虚拟软件来说,有三种网络模式 1.桥接 2.NAT 3.Host-only 桥接 桥接网络是指本地物理网卡和虚拟网卡通过VMnet0虚拟交换机进行桥接,因此物理网卡和虚 ...
- [haoi2014]贴海报
Bytetown城市要进行市长竞选,所有的选民可以畅所欲言地对竞选市长的候选人发表言论.为了统一管理,城市委员会为选民准备了一个张贴海报的electoral墙.张贴规则如下:1.electoral墙是 ...
- Kattis - whatdoesthefoxsay —— 字符串
题目: Kattis - whatdoesthefoxsay Determined to discover the ancient mystery—the sound that the fox ...
- 阿里云数据库产品HybridDB简介——OLAP数据库,支持行列混合存储,基于数据库Greenplum的开源版本,并且吸收PostgreSQL精髓
为什么会有HybridDB的诞生?它经历了怎样的研发历程?它的应用场景和情况是怎样的?带着这些问题,InfoQ对阿里云的数据库专家兼Postgres中国社区/中国用户会主席萧少聪先生进行了采访,以下文 ...
- C++之面向对象初探----对象管理模型(关键是this指针)
前言 c++对象模型可以概括为以下2部分 1.语言中直接支持面向对象程序员设计部分,主要涉及如构造函数.析构函数.虚函数.继承(单继承.多继承.虚继承).多态等待. 2.对于各种支持的底层实现机制 在 ...