From 60209f15e96508cae4fe30b4388f99ad828eddbc Mon Sep 17 00:00:00 2001 From: Helmi Akermi <70575401+hakermi@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:59:05 +0100 Subject: [PATCH] fix: fix exception of unrecognized alias on hsqldb - EXO - EXO-65151 - Meeds-io/MIPs#69 (#164) Prior to this change, On hsqldb an exception is thrown when the UP is executed because of unrecognized use alias for SALT128 attribute. This PR changes the request to avoid using alias and prevent the issue. --- .../migration/UserPasswordHashMigration.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/data-upgrade-users/src/main/java/org/exoplatform/migration/UserPasswordHashMigration.java b/data-upgrade-users/src/main/java/org/exoplatform/migration/UserPasswordHashMigration.java index 4803846a1..3fa15d2d1 100644 --- a/data-upgrade-users/src/main/java/org/exoplatform/migration/UserPasswordHashMigration.java +++ b/data-upgrade-users/src/main/java/org/exoplatform/migration/UserPasswordHashMigration.java @@ -32,9 +32,7 @@ import javax.persistence.EntityManager; import javax.persistence.Query; import java.security.SecureRandom; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; public class UserPasswordHashMigration extends UpgradeProductPlugin { @@ -73,12 +71,11 @@ public void processUpgrade(String s, String s1) { AtomicInteger updatedPasswords = new AtomicInteger(); EntityManager entityManager = this.entityManagerService.getEntityManager(); try { - String sqlString = "SELECT jbid_io.NAME, jbid_io_creden.TEXT FROM" + - " (jbid_io_creden INNER JOIN jbid_io ON jbid_io_creden.IDENTITY_OBJECT_ID = jbid_io.ID)" + - " INNER JOIN (SELECT jbid_io_attr.IDENTITY_OBJECT_ID," + - " min(CASE WHEN jbid_io_attr.NAME = 'passwordSalt128' THEN jbid_io_attr.NAME ELSE NULL END) AS salt128" + - " FROM jbid_io_attr GROUP BY jbid_io_attr.IDENTITY_OBJECT_ID" + - " HAVING salt128 IS NULL) jia ON jbid_io_creden.IDENTITY_OBJECT_ID = jia.IDENTITY_OBJECT_ID;"; + String sqlString = "SELECT jbid_io.NAME, jbid_io_creden.TEXT FROM" + + " (jbid_io_creden INNER JOIN jbid_io ON jbid_io_creden.IDENTITY_OBJECT_ID = jbid_io.ID)" + + " INNER JOIN (SELECT jbid_io_attr.IDENTITY_OBJECT_ID FROM jbid_io_attr" + + " WHERE NOT EXISTS (SELECT jbid_io_attr.IDENTITY_OBJECT_ID FROM jbid_io_attr WHERE NAME = 'passwordSalt128')" + + " GROUP BY jbid_io_attr.IDENTITY_OBJECT_ID) jia ON jbid_io_creden.IDENTITY_OBJECT_ID = jia.IDENTITY_OBJECT_ID;"; Query nativeQuery = entityManager.createNativeQuery(sqlString); List result = nativeQuery.getResultList();