Skip to content

Commit

Permalink
Add registration key field in query
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasCwy committed Apr 24, 2024
1 parent 2272666 commit b857425
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,18 @@ protected void migrateEntity(teammates.storage.entity.AccountRequest oldEntity)

cr.select(root).where(cb.equal(root.get("institute"), oldEntity.getInstitute()))
.where(cb.equal(root.get("email"), oldEntity.getEmail()))
.where(cb.equal(root.get("name"), oldEntity.getName()));
.where(cb.equal(root.get("name"), oldEntity.getName()))
.where(cb.equal(root.get("registrationKey"), oldEntity.getRegistrationKey()));

List<teammates.storage.sqlentity.AccountRequest> matchingAccounts = HibernateUtil.createQuery(cr).getResultList();

if (matchingAccounts.size() > 1) {
throw new Error("More than one matching account request found");
} else if (matchingAccounts.size() == 0){
if (matchingAccounts.size() == 0){
throw new Error("No matching account found");
}

if (matchingAccounts.size() > 1) {
throw new Error("More than one matching account request found");
}

// Get first items since there is guaranteed to be one
teammates.storage.sqlentity.AccountRequest newAccountReq = matchingAccounts.get(0);
Expand Down

0 comments on commit b857425

Please sign in to comment.