Skip to content

Commit

Permalink
fix: fix exception of unrecognized alias on hsqldb - EXO - EXO-65151 -
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
hakermi authored Aug 1, 2023
1 parent 1a278a2 commit 60209f1
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Object[]> result = nativeQuery.getResultList();
Expand Down

0 comments on commit 60209f1

Please sign in to comment.