コード例 #1
0
 @Override
 public boolean apply(@Nullable Class aClass) {
   EntityTransaction tran = Entities.get(AccountEntity.class);
   try {
     List<AccountEntity> accounts = Entities.query(new AccountEntity());
     if (accounts != null && accounts.size() > 0) {
       for (AccountEntity account : accounts) {
         if (account.getCanonicalId() == null || account.getCanonicalId().equals("")) {
           account.setCanonicalId(genCanonicalId());
           LOG.debug(
               "putting canonical id "
                   + account.getCanonicalId()
                   + " on account "
                   + account.getAccountNumber());
         }
       }
     }
     tran.commit();
   } catch (Exception ex) {
     tran.rollback();
     LOG.error(
         "caught exception during upgrade, while attempting to generate and assign canonical ids");
     Exceptions.toUndeclared(ex);
   }
   return true;
 }
コード例 #2
0
 public static AccountEntity newInstanceWithAccountNumber(String accountNumber) {
   AccountEntity a = new AccountEntity();
   a.setAccountNumber(accountNumber);
   return a;
 }