Skip to content

Commit d36a36f

Browse files
committed
[#10172] Improved ambiguous classpath of mybatis mapper
1 parent e419f7c commit d36a36f

13 files changed

+339
-291
lines changed

batch/src/main/resources/applicationContext-batch-dao-config.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
2222
<property name="dataSource" ref="dataSource"/>
2323
<!-- mybatis basic config -->
24-
<property name="configLocation" value="classpath:/batch-mybatis-config.xml"/>
24+
<property name="configLocation" value="classpath:/batch/batch-mybatis-config.xml"/>
2525
<!-- typeAliases -->
2626
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.web.alarm.vo" />
2727
<!-- setting the location of mapper -->
28-
<property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
28+
<property name="mapperLocations" value="classpath*:/batch/mapper/*Mapper.xml"/>
2929
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
3030
<property name="failFast" value="true"/>
3131

batch/src/main/resources/batch-mybatis-config.xml batch/src/main/resources/batch/batch-mybatis-config.xml

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2023 NAVER Corp.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
219
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
320
"http://mybatis.org/dtd/mybatis-3-config.dtd">
421

pinot/pinot-batch/src/main/resources/mapper/alarm/PinotAlarmMapper.xml pinot/pinot-batch/src/main/resources/alarm/mapper/PinotAlarmMapper.xml

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
~ Copyright 2023 NAVER Corp.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
219
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
320

421
<mapper namespace="com.navercorp.pinpoint.batch.alarm.dao.PinotAlarmDao">

pinot/pinot-batch/src/main/resources/pinot-alarm-mybatis-config.xml pinot/pinot-batch/src/main/resources/alarm/pinot-alarm-mybatis-config.xml

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2023 NAVER Corp.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
219
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
320
"http://mybatis.org/dtd/mybatis-3-config.dtd">
421

pinot/pinot-batch/src/main/resources/applicationContext-pinot-batch-dao-config.xml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:aop="http://www.springframework.org/schema/aop"
5-
xmlns:tx="http://www.springframework.org/schema/tx"
64
xmlns:context="http://www.springframework.org/schema/context"
75
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8-
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
9-
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
6+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
107

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

@@ -16,9 +13,9 @@
1613

1714
<bean id="uriStatPinotSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
1815
<property name="dataSource" ref="pinotAlarmDataSource"/>
19-
<property name="configLocation" value="classpath:/pinot-alarm-mybatis-config.xml"/>
16+
<property name="configLocation" value="classpath:/alarm/pinot-alarm-mybatis-config.xml"/>
2017
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.batch.alarm.vo" />
21-
<property name="mapperLocations" value="classpath:mapper/alarm/*Mapper.xml"/>
18+
<property name="mapperLocations" value="classpath:/alarm/mapper/*Mapper.xml"/>
2219
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
2320
<property name="failFast" value="true"/>
2421
<property name="transactionFactory" ref="transactionFactory"/>

web/src/main/resources/applicationContext-web-dao-config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<!-- typeAliases -->
2626
<property name="typeAliasesPackage" value="com.navercorp.pinpoint.web.alarm.vo" />
2727
<!-- setting the location of mapper -->
28-
<property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
28+
<property name="mapperLocations" value="classpath*:web/mapper/*Mapper.xml"/>
2929
<!-- set "true" in order to catch the errors of declaration of statement more quickly -->
3030
<property name="failFast" value="true"/>
3131

Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3-
4-
<mapper namespace="com.navercorp.pinpoint.web.dao.AlarmDao">
5-
6-
<insert id="insertRule" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
7-
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, webhook_send, notes)
8-
VALUES
9-
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{webhookSend}, #{notes})
10-
</insert>
11-
12-
<insert id="insertRuleExceptWebhookSend" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
13-
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, notes)
14-
VALUES
15-
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
16-
</insert>
17-
18-
<delete id="deleteRule" parameterType="Rule">
19-
DELETE
20-
FROM alarm_rule
21-
WHERE rule_id = #{ruleId}
22-
</delete>
23-
24-
<select id="selectRuleByUserGroupId" resultType="Rule">
25-
SELECT *
26-
FROM alarm_rule
27-
WHERE user_group_id = #{userGroupId}
28-
</select>
29-
30-
<select id="selectRuleByApplicationId" resultType="Rule">
31-
SELECT *
32-
FROM alarm_rule
33-
WHERE application_id = #{applicationId}
34-
</select>
35-
36-
<select id="selectApplicationId" resultType="string">
37-
SELECT DISTINCT(application_id)
38-
FROM alarm_rule
39-
</select>
40-
41-
<update id="updateRule">
42-
UPDATE alarm_rule
43-
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}
44-
WHERE rule_id = #{ruleId}
45-
</update>
46-
47-
48-
<update id="updateRuleExceptWebhookSend">
49-
UPDATE alarm_rule
50-
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
51-
WHERE rule_id = #{ruleId}
52-
</update>
53-
54-
<update id="updateUserGroupIdOfRule" parameterType="UserGroup">
55-
UPDATE alarm_rule
56-
SET user_group_id = #{id}
57-
WHERE user_group_id = (SELECT id FROM user_group WHERE number = #{number})
58-
</update>
59-
60-
<delete id="deleteCheckerResult" parameterType="string">
61-
DELETE
62-
FROM alarm_history
63-
WHERE rule_id = #{ruleId}
64-
</delete>
65-
66-
</mapper>
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3+
4+
<mapper namespace="com.navercorp.pinpoint.web.dao.AlarmDao">
5+
6+
<insert id="insertRule" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
7+
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, webhook_send, notes)
8+
VALUES
9+
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{webhookSend}, #{notes})
10+
</insert>
11+
12+
<insert id="insertRuleExceptWebhookSend" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
13+
INSERT INTO alarm_rule (application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, notes)
14+
VALUES
15+
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
16+
</insert>
17+
18+
<delete id="deleteRule" parameterType="Rule">
19+
DELETE
20+
FROM alarm_rule
21+
WHERE rule_id = #{ruleId}
22+
</delete>
23+
24+
<select id="selectRuleByUserGroupId" resultType="Rule">
25+
SELECT *
26+
FROM alarm_rule
27+
WHERE user_group_id = #{userGroupId}
28+
</select>
29+
30+
<select id="selectRuleByApplicationId" resultType="Rule">
31+
SELECT *
32+
FROM alarm_rule
33+
WHERE application_id = #{applicationId}
34+
</select>
35+
36+
<select id="selectApplicationId" resultType="string">
37+
SELECT DISTINCT(application_id)
38+
FROM alarm_rule
39+
</select>
40+
41+
<update id="updateRule">
42+
UPDATE alarm_rule
43+
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}
44+
WHERE rule_id = #{ruleId}
45+
</update>
46+
47+
48+
<update id="updateRuleExceptWebhookSend">
49+
UPDATE alarm_rule
50+
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
51+
WHERE rule_id = #{ruleId}
52+
</update>
53+
54+
<update id="updateUserGroupIdOfRule" parameterType="UserGroup">
55+
UPDATE alarm_rule
56+
SET user_group_id = #{id}
57+
WHERE user_group_id = (SELECT id FROM user_group WHERE number = #{number})
58+
</update>
59+
60+
<delete id="deleteCheckerResult" parameterType="string">
61+
DELETE
62+
FROM alarm_history
63+
WHERE rule_id = #{ruleId}
64+
</delete>
65+
66+
</mapper>

0 commit comments

Comments
 (0)