Skip to content

Commit

Permalink
[#10172] Improved ambiguous classpath of mybatis mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jul 27, 2023
1 parent e419f7c commit d36a36f
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- mybatis basic config -->
<property name="configLocation" value="classpath:/batch-mybatis-config.xml"/>
<property name="configLocation" value="classpath:/batch/batch-mybatis-config.xml"/>
<!-- typeAliases -->
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.web.alarm.vo" />
<!-- setting the location of mapper -->
<property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
<property name="mapperLocations" value="classpath*:/batch/mapper/*Mapper.xml"/>
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
<property name="failFast" value="true"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 NAVER Corp.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2023 NAVER Corp.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.navercorp.pinpoint.batch.alarm.dao.PinotAlarmDao">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2023 NAVER Corp.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

<context:component-scan base-package="com.navercorp.pinpoint.batch.alarm.dao"/>

Expand All @@ -16,9 +13,9 @@

<bean id="uriStatPinotSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="pinotAlarmDataSource"/>
<property name="configLocation" value="classpath:/pinot-alarm-mybatis-config.xml"/>
<property name="configLocation" value="classpath:/alarm/pinot-alarm-mybatis-config.xml"/>
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.batch.alarm.vo" />
<property name="mapperLocations" value="classpath:mapper/alarm/*Mapper.xml"/>
<property name="mapperLocations" value="classpath:/alarm/mapper/*Mapper.xml"/>
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
<property name="failFast" value="true"/>
<property name="transactionFactory" ref="transactionFactory"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!-- typeAliases -->
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.web.alarm.vo" />
<!-- setting the location of mapper -->
<property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
<property name="mapperLocations" value="classpath*:web/mapper/*Mapper.xml"/>
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
<property name="failFast" value="true"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
<?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.navercorp.pinpoint.web.dao.AlarmDao">

<insert id="insertRule" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, webhook_send, notes)
VALUES
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{webhookSend}, #{notes})
</insert>

<insert id="insertRuleExceptWebhookSend" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, notes)
VALUES
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
</insert>

<delete id="deleteRule" parameterType="Rule">
DELETE
FROM alarm_rule
WHERE rule_id = #{ruleId}
</delete>

<select id="selectRuleByUserGroupId" resultType="Rule">
SELECT *
FROM alarm_rule
WHERE user_group_id = #{userGroupId}
</select>

<select id="selectRuleByApplicationId" resultType="Rule">
SELECT *
FROM alarm_rule
WHERE application_id = #{applicationId}
</select>

<select id="selectApplicationId" resultType="string">
SELECT DISTINCT(application_id)
FROM alarm_rule
</select>

<update id="updateRule">
UPDATE alarm_rule
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, webhook_send = #{webhookSend}, notes = #{notes}
WHERE rule_id = #{ruleId}
</update>


<update id="updateRuleExceptWebhookSend">
UPDATE alarm_rule
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
WHERE rule_id = #{ruleId}
</update>

<update id="updateUserGroupIdOfRule" parameterType="UserGroup">
UPDATE alarm_rule
SET user_group_id = #{id}
WHERE user_group_id = (SELECT id FROM user_group WHERE number = #{number})
</update>

<delete id="deleteCheckerResult" parameterType="string">
DELETE
FROM alarm_history
WHERE rule_id = #{ruleId}
</delete>

</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.navercorp.pinpoint.web.dao.AlarmDao">

<insert id="insertRule" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, webhook_send, notes)
VALUES
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{webhookSend}, #{notes})
</insert>

<insert id="insertRuleExceptWebhookSend" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, notes)
VALUES
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
</insert>

<delete id="deleteRule" parameterType="Rule">
DELETE
FROM alarm_rule
WHERE rule_id = #{ruleId}
</delete>

<select id="selectRuleByUserGroupId" resultType="Rule">
SELECT *
FROM alarm_rule
WHERE user_group_id = #{userGroupId}
</select>

<select id="selectRuleByApplicationId" resultType="Rule">
SELECT *
FROM alarm_rule
WHERE application_id = #{applicationId}
</select>

<select id="selectApplicationId" resultType="string">
SELECT DISTINCT(application_id)
FROM alarm_rule
</select>

<update id="updateRule">
UPDATE alarm_rule
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, webhook_send = #{webhookSend}, notes = #{notes}
WHERE rule_id = #{ruleId}
</update>


<update id="updateRuleExceptWebhookSend">
UPDATE alarm_rule
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
WHERE rule_id = #{ruleId}
</update>

<update id="updateUserGroupIdOfRule" parameterType="UserGroup">
UPDATE alarm_rule
SET user_group_id = #{id}
WHERE user_group_id = (SELECT id FROM user_group WHERE number = #{number})
</update>

<delete id="deleteCheckerResult" parameterType="string">
DELETE
FROM alarm_history
WHERE rule_id = #{ruleId}
</delete>

</mapper>
Loading

0 comments on commit d36a36f

Please sign in to comment.