Skip to content

Commit

Permalink
Revert "Add changes (TEAMMATES#12965)"
Browse files Browse the repository at this point in the history
This reverts commit 1292dbe.
  • Loading branch information
mingyuanc committed Apr 14, 2024
1 parent be996e8 commit 671af22
Showing 1 changed file with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
import com.google.cloud.datastore.QueryResults;
import com.googlecode.objectify.cmd.Query;

import jakarta.persistence.TypedQuery;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Root;

// import jakarta.persistence.criteria.CriteriaDelete;

import teammates.client.connector.DatastoreClient;
Expand Down Expand Up @@ -131,27 +126,6 @@ private void doMigration(teammates.storage.entity.Account entity) {
* Migrates the entity.
*/
protected void migrateEntity(teammates.storage.entity.Account oldAccount) {
HibernateUtil.beginTransaction();

CriteriaBuilder cb = HibernateUtil.getCriteriaBuilder();
CriteriaQuery<teammates.storage.sqlentity.Account> cr = cb.createQuery(
teammates.storage.sqlentity.Account.class);
Root<teammates.storage.sqlentity.Account> root = cr.from(teammates.storage.sqlentity.Account.class);
cr.select(root).where(cb.equal(root.get("googleId"), oldAccount.getGoogleId()));

TypedQuery<teammates.storage.sqlentity.Account> query = HibernateUtil.createQuery(cr);


boolean isEntityInDb = query.getResultList().size() != 0;
HibernateUtil.commitTransaction();

// In db, but somehow not set as migrated.
if (isEntityInDb) {
oldAccount.setMigrated(true);
entitiesOldAccountSavingBuffer.add(oldAccount);
return;
};

teammates.storage.sqlentity.Account newAccount = new teammates.storage.sqlentity.Account(
oldAccount.getGoogleId(),
oldAccount.getName(),
Expand All @@ -162,6 +136,7 @@ protected void migrateEntity(teammates.storage.entity.Account oldAccount) {
oldAccount.setMigrated(true);
entitiesOldAccountSavingBuffer.add(oldAccount);
migrateReadNotification(oldAccount, newAccount);

}

private void migrateReadNotification(teammates.storage.entity.Account oldAccount,
Expand Down

0 comments on commit 671af22

Please sign in to comment.