首页 技术 正文
技术 2022年11月9日
0 收藏 333 点赞 2,332 浏览 2544 个字
添加新的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>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289