Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#10172] Improved ambiguous classpath of mybatis mapper #10173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions web/src/main/resources/applicationContext-web-dao-config.xml
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:/mybatis-config.xml"/>
<property name="configLocation" value="classpath:/web/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*: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