java_mybatis

发布时间:2020-06-14 15:36:22 作者:zjy1002261870
来源:网络 阅读:267

<?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>
<properties resource="META-INF/properties/dbms.properties"></properties>
<settings>

    <setting name="cacheEnabled" value="true" />                                        <!-- mybatis cache 사용여부 -->
    <setting name="lazyLoadingEnabled" value="true" />                              <!-- 지연로딩 사용여부 -->
    <setting name="multipleResultSetsEnabled" value="true" />                       <!-- 한 개의 구문에서 여러 개의 ResultSet을 허용할지 여부 -->
    <setting name="useColumnLabel" value="true" />                                  <!-- 컬럼명 대신 컬럼 라벨을 사용 -->
    <setting name="useGeneratedKeys" value="false" />                               <!-- 생성키에 대한 JDBC 지원 허용 여부 -->
    <setting name="autoMappingBehavior" value="PARTIAL" />                          <!-- mybatis가 컬럼을 필드/프로퍼티에 자동으로 매핑할지와 방법에 대한 명시(PARTIAL은 중첩되지 않은 것들을 매핑 -->
    <setting name="defaultExecutorType" value="SIMPLE" />                           <!-- 디폴트 Executor 설정(SIMPLE은 특별히 동작하는 것은 업음) -->
    <setting name="defaultStatementTimeout" value="10" />                           <!-- DB 응답 타임아웃 설정 -->
    <setting name="safeRowBoundsEnabled" value="false" />                           <!-- 중첩구문내 RowBound 사용 허용여부 -->
    <setting name="mapUnderscoreToCamelCase" value="false" />                       <!-- 전통적 DB 컴럼명을 JAVA의 Camel표기법으로 자동 매핑 설정 -->
    <setting name="localCacheScope" value="SESSION" />                              <!-- 로컬캐시 사용여부(SESSION: 세션을 사용해서 모든쿼리를 캐시) -->
    <setting name="jdbcTypeForNull" value="NULL" />                                 <!-- mybatis로 넘어오는 parameter가 null인 경우, jdbcType을 Setting -->
    <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" />    <!-- 지연로딩을 야기하는 객체의 메소드를 명시 -->
    <setting name="callSettersOnNulls" value="true" />                              <!-- 가져온 값이 null일때 setter나 맵의 put 메소드를 호출할지를 명시 (false일경우, null인 field는 제거되어 나타남 : default는 false -->

</settings>

<mappers>
    <!-- <property name="mapperLocations" value="classpath:META-INF/persistence/mybatis/${dbms.kind}/*Mapper.xml"></property>  -->
    <mapper resource="META-INF/persistence/mybatis/${dbms.kind}/GoodsMapper.xml" />
    <mapper resource="META-INF/persistence/mybatis/${dbms.kind}/Paging.xml" />
    <mapper resource="META-INF/persistence/mybatis/${dbms.kind}/SurveyMapper.xml" />
</mappers>

</configuration>
<?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="paging">

<!-- 패이징을 위한 샘플 QUERY 입니다..업무에 맞게 수정하셔서 사용 바랍니다.. -->
<sql id="pagingPreSQL">
    SELECT * FROM (
    SELECT ROWNUM AS "ROWNUMBER" , AA.* FROM (
</sql>

<sql id="pagingPostSQL">
    ) AA ) AAA
     <![CDATA[
        WHERE AAA.ROWNUMBER  >= #{firstRowIndex} AND  AAA.ROWNUMBER  <= #{lastRowIndex}
     ]]>
</sql>

<sql id="pagingPreSqlOverCount">
    SELECT FLOOR((AA.totalCount-1)/#{rowPerPage})+1 totalPage , AA.* FROM (
    SELECT COUNT(*) OVER() totalCount, ROWNUM ROWNUMBER,MAINSQL.* FROM
    (
</sql>

<sql id="pagingPostSqlOverCount">

    ) MAINSQL 
     <![CDATA[ ) AA WHERE ROWNUMBER>=((#{pageNo}-1)*#{rowPerPage})+1 AND ROWNUMBER <= (((#{pageNo}-1)*#{rowPerPage})+1) + #{rowPerPage}-1 ]]>
</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="FileUploadDataMapper">

<select id="getFileUploadData" parameterType="java.util.Map"
    resultType="java.util.Map">
    SELECT [Number]
    ,[FileGuid]
    ,[FileId]
    ,[FilePath]
    ,[FileName]
    ,[FileType]
    ,[FileSize]
    ,[CreateTime]
    FROM [dbo].[AA_FileUploadData]
    WHERE 1=1

    <if test="FileGuid !=null and FileGuid !='' ">
        AND FileGuid= #{FileGuid}
    </if>
    <if test="FileId !=null and FileId !='' ">
        AND FileId= #{FileId}
    </if>
</select>

<select id="getFileUploadDataList" parameterType="java.util.Map"
    resultType="java.util.Map">
    <include refid="paging.pagingPreSQL" />
    select ROW_NUMBER() over(order by Number desc )
    rownum,[Number]
    ,[FileGuid]
    ,[FileId]
    ,[FilePath]
    ,[FileName]
    ,[FileType]
    ,[FileSize]
    ,[CreateTime]
    from AA_FileUploadData
    where 1=1
    <if test="FileGuid !=null and FileGuid !='' ">
        AND FileGuid= #{FileGuid}
    </if>
    <if test="FileId !=null and FileId !='' ">
        AND FileId= #{FileId}
    </if>
    <include refid="paging.pagingPostSQL" />
</select>
<select id="getFileUploadDataListCnt" parameterType="java.util.Map"
    resultType="java.lang.Integer">
    select count(1) as "totalCnt"
    from AA_FileUploadData
    where 1=1
    <if test="FileGuid !=null and FileGuid !='' ">
        AND FileGuid= #{FileGuid}
    </if>
    <if test="FileId !=null and FileId !='' ">
        AND FileId= #{FileId}
    </if>
</select>
<!-- useGeneratedKeys="true" keyProperty="GoodsID" -->

<insert id="insertFileUploadData" parameterType="java.util.Map">
    <selectKey resultType="int" keyProperty="Number" order="AFTER">
        select
        @@IDENTITY as id
    </selectKey>
    INSERT INTO [dbo].[AA_FileUploadData]
    ([FileGuid]
    ,[FileId]
    ,[FilePath]
    ,[FileName]
    ,[FileType]
    ,[FileSize]
    ,[CreateTime])
    VALUES
    (
    #{FileGuid},
    #{FileId},
    #{FilePath},
    #{FileName},
    #{FileType},
    #{FileSize},
    GetDate()
    )
</insert>

<delete id="deleteFileUploadData" parameterType="java.util.Map">
    DELETE FROM AA_FileUploadData
    WHERE FileGuid = #{FileGuid}
    <if test="FileId !=null and FileId !='' ">
        AND FileId = #{FileId}
    </if>
</delete>

</mapper>

推荐阅读:
  1. MongoDB导出场景查询优化 #1
  2. Java与JavaScript的区别有哪些

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

java my batis

上一篇:Exchange Server 2016 DAG FailedAndSuspended

下一篇:ueditor 百度编辑器 配置如何上传图片

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》