mybatis

来源:互联网 发布:excel复制一列数据变少 编辑:程序博客网 时间:2024/05/02 04:36

配置文件

<?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.yystar.sb2ph.dao.TeamDao">
    <resultMap type="com.yystar.sb2ph.domain.Team" id="teamMap">
        <result property="teamId" column="TeamId" />
        <result property="teamName" column="TeamName" />
        <result property="sportId" column="sportId" />
        <result property="leagueId1" column="LeagueId1" />
        <result property="leagueId2" column="LeagueId2" />
        <result property="leagueId3" column="LeagueId3" />
        <result property="remark" column="Remark" />
        <association property="textResource" resultMap="textResourceMap" />
        <association property="shortTextResource" resultMap="shortTextresourceMap" />
    </resultMap>
    
    <resultMap type="com.yystar.sb2ph.domain.TextResource" id="textResourceMap">
        <result property="en" column="Text_en" />
        <result property="zhCn" column="Text_zh_cn" />
        <result property="zhTw" column="Text_zh_tw" />
        <result property="th" column="Text_th" />
        <result property="vi" column="Text_vi" />
        <result property="in" column="Text_in" />
        <result property="jp" column="Text_jp" />
        <result property="pt" column="Text_pt" />
        <result property="br" column="Text_br" />
        <result property="ru" column="Text_ru" />
        <result property="de" column="Text_de" />
    </resultMap>
    
    <resultMap type="com.yystar.sb2ph.domain.TextResource" id="shortTextresourceMap">
        <result property="en" column="ShortText_en" />
        <result property="zhCn" column="ShortText_zh_cn" />
        <result property="zhTw" column="ShortText_zh_tw" />
        <result property="th" column="ShortText_th" />
        <result property="vi" column="ShortText_vi" />
        <result property="in" column="ShortText_in" />
        <result property="jp" column="ShortText_jp" />
        <result property="pt" column="ShortText_pt" />
        <result property="br" column="ShortText_br" />
        <result property="ru" column="ShortText_ru" />
        <result property="de" column="ShortText_de" />
    </resultMap>
    
    <sql id="teamColums">
        "TeamId",
        "TeamName",
        "SportId",
        "LeagueId1",
        "LeagueId2",
        "LeagueId3",
        "Text_en",
        "Text_zh_cn",
        "Text_zh_tw",
        "Text_th",
        "Text_vi",
        "Text_in",
        "Text_jp",
        "Text_pt",
        "Text_br",
        "Text_ru",
        "Text_de",
        "ShortText_en",
        "ShortText_zh_cn",
        "ShortText_zh_tw",
        "ShortText_th",
        "ShortText_vi",
        "ShortText_in",
        "ShortText_jp",
        "ShortText_pt",
        "ShortText_br",
        "ShortText_ru",
        "ShortText_de",
        "CreateDateTime",
        "CreateUserCode",
        "LastUpdateDateTime",
        "LastUpdateUserCode",
        "Remark"
    </sql>
    
    <select id="getTeamById" parameterType="int" resultMap="teamMap">
        SELECT
            <include refid="teamColums" />
        FROM
            "BPTeam"
        WHERE
            "TeamId" = #{teamId}
    </select>
    
    <select id="getTeams" parameterType="int" resultMap="teamMap">
        SELECT
            <include refid="teamColums" />
        FROM
            "BPTeam"
    </select>
    
    <select id="getTeamIdByName" parameterType="map" resultType="int">
        SELECT
            "TeamId"
        FROM
            "BPTeam"
        WHERE
            "TeamName" = #{teamName}
        <if test="leagueId > 0">
        AND ("LeagueId1" = #{leagueId}
            OR "LeagueId2" = #{leagueId}
            OR "LeagueId3" = #{leagueId})
        </if>
    </select>
    
    
    <select id="getTeamShortTextByName" resultMap="teamMap">
        SELECT
            "ShortText_en",
            "ShortText_zh_cn",
            "ShortText_zh_tw",
            "ShortText_th",
            "ShortText_vi",
            "ShortText_in",
            "ShortText_jp",
            "ShortText_pt",
            "ShortText_br",
            "ShortText_ru",
            "ShortText_de"
        FROM
            "BPTeam"
        WHERE
            "BPTeam"."TeamName" = #{teamName}
    </select>
</mapper>


任意公共方法的执行:
execution(public * *(..))
任何一个以“set”开始的方法的执行:
execution(* set*(..))
AccountService 接口的任意方法的执行:
execution(* com.xyz.service.AccountService.*(..))
定义在service包里的任意方法的执行:
execution(* com.xyz.service.*.*(..))
定义在service包或者子包里的任意方法的执行:
execution(* com.xyz.service..*.*(..))
在service包里的任意连接点(在Spring AOP中只是方法执行) :
within(com.xyz.service.*)
在service包或者子包里的任意连接点(在Spring AOP中只是方法执行) :
within(com.xyz.service..*)
实现了 AccountService 接口的代理对象的任意连接点(在Spring AOP中只是方法执行) :
this(com.xyz.service.AccountService)
'this'在binding form中用的更多:- 请常见以下讨论通知的章节中关于如何使得代理对象可以在通知体内访问到的部分。
实现了 AccountService 接口的目标对象的任意连接点(在Spring AOP中只是方法执行) :
target(com.xyz.service.AccountService)
'target'在binding form中用的更多:- 请常见以下讨论通知的章节中关于如何使得目标对象可以在通知体内访问到的部分。
任何一个只接受一个参数,且在运行时传入的参数实现了 Serializable 接口的连接点 (在Spring AOP中只是方法执行)
args(java.io.Serializable)
'args'在binding form中用的更多:- 请常见以下讨论通知的章节中关于如何使得方法参数可以在通知体内访问到的部分。 请注意在例子中给出的切入点不同于 execution(* *(java.io.Serializable)): args只有在动态运行时候传入参数是可序列化的(Serializable)才匹配,而execution 在传入参数的签名声明的类型实现了 Serializable 接口时候匹配。
有一个 @Transactional 注解的目标对象中的任意连接点(在Spring AOP中只是方法执行)
@target(org.springframework.transaction.annotation.Transactional)
'@target' 也可以在binding form中使用:请常见以下讨论通知的章节中关于如何使得annotation对象可以在通知体内访问到的部分。
任何一个目标对象声明的类型有一个 @Transactional 注解的连接点(在Spring AOP中只是方法执行)
@within(org.springframework.transaction.annotation.Transactional)
'@within'也可以在binding form中使用:- 请常见以下讨论通知的章节中关于如何使得annotation对象可以在通知体内访问到的部分。
任何一个执行的方法有一个 @Transactional annotation的连接点(在Spring AOP中只是方法执行)
@annotation(org.springframework.transaction.annotation.Transactional)
'@annotation' 也可以在binding form中使用:- 请常见以下讨论通知的章节中关于如何使得annotation对象可以在通知体内访问到的部分。
任何一个接受一个参数,并且传入的参数在运行时的类型实现了 @Classified annotation的连接点(在Spring AOP中只是方法执行)
@args(com.xyz.security.Classified)


    <aop:config>  
        <aop:aspect id="sb2PhAspect" ref="sb2PhAspect">  
            <!--配置com.yystar.sb2ph.service.impl包下所有类或接口的所有方法-->  
            <aop:pointcut id="businessService"  
                expression="execution(* com.yystar.sb2ph.service.impl.*.*(..))" />  
            <aop:before pointcut-ref="businessService" method="doBefore"/>  
            <aop:after pointcut-ref="businessService" method="doAfter"/>  
            <aop:around pointcut-ref="businessService" method="doAround"/>  
            <aop:after-throwing pointcut-ref="businessService" method="doThrowing" throwing="ex"/>
        </aop:aspect>  
    </aop:config>






原创粉丝点击