com.liferay.notification.internal.upgrade.v3_8_0.NotificationQueueEntryUpgradeProcess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.notification.service
Show all versions of com.liferay.notification.service
Liferay Notification Service
/**
* SPDX-FileCopyrightText: (c) 2023 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.notification.internal.upgrade.v3_8_0;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.dao.jdbc.AutoBatchPreparedStatementUtil;
import com.liferay.portal.kernel.upgrade.UpgradeProcess;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
* @author Selton Guedes
*/
public class NotificationQueueEntryUpgradeProcess extends UpgradeProcess {
@Override
protected void doUpgrade() throws Exception {
try (PreparedStatement preparedStatement1 = connection.prepareStatement(
StringBundler.concat(
"select distinct NotificationQueueEntry.",
"notificationTemplateId, NotificationTemplate.companyId ",
"from NotificationQueueEntry inner join ",
"NotificationTemplate on NotificationQueueEntry.",
"notificationTemplateId = NotificationTemplate.",
"notificationTemplateId where NotificationQueueEntry.",
"companyId = 0"));
PreparedStatement preparedStatement2 =
AutoBatchPreparedStatementUtil.concurrentAutoBatch(
connection,
"update NotificationQueueEntry set companyId = ? where " +
"notificationTemplateId = ?");
ResultSet resultSet = preparedStatement1.executeQuery()) {
while (resultSet.next()) {
preparedStatement2.setLong(1, resultSet.getLong("companyId"));
preparedStatement2.setLong(
2, resultSet.getLong("notificationTemplateId"));
preparedStatement2.addBatch();
}
preparedStatement2.executeBatch();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy