@Test public void getsAnExistingAccountByUsernameAndPassword() { Account persistedAccount = createAccountBuilderWithAllFieldsWithBannerData().build(); String username = persistedAccount.getUsername(); String password = persistedAccount.getPassword(); persistence.getEntityManager().persist(persistedAccount); assertThat(persistedAccount.getVersion(), notNullValue()); persistence.flushContext(); persistence.detachEntity(persistedAccount); assertFalse(persistence.contextContains(persistedAccount)); Account existingAccount = persistence.getAccountByUsernameAndPassword(username, password); assertReflectionEquals(persistedAccount, existingAccount); }
public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { Account result = null; Query query = createNamedQuery("Account.getAccountByUsernameAndPassword"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); checkState(accounts.size() <= 1, String.format("Query[Account" + ".getAccountByUsernameAndPassword] with parameters[%s,%s] returned [%d] results", username, password, accounts.size())); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }
AccountBasePersistence extends AbstractBasePersistence<Account, String> implements AccountMapper { public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { Account result = null; Query query = createNamedQuery("Account.getAccountByUsernameAndPassword"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); checkState(accounts.size() <= 1, String.format("Query[Account" + ".getAccountByUsernameAndPassword] with parameters[%s,%s] returned [%d] results", username, password, accounts.size())); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; } }
AccountBasePersistence extends AbstractBasePersistence<Account, String> implements AccountMapper { public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { Account result = null; Query query = createNamedQuery("Account.getAccountByUsernameAndPassword"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); checkState(accounts.size() <= 1, String.format("Query[Account" + ".getAccountByUsernameAndPassword] with parameters[%s,%s] returned [%d] results", username, password, accounts.size())); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }  }
AccountBasePersistence extends AbstractBasePersistence<Account, String> implements AccountMapper { public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { Account result = null; Query query = createNamedQuery("Account.getAccountByUsernameAndPassword"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); checkState(accounts.size() <= 1, String.format("Query[Account" + ".getAccountByUsernameAndPassword] with parameters[%s,%s] returned [%d] results", username, password, accounts.size())); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }  Account getAccountByUsername(@Nonnull final String username); Account getAccountByUsernameAndPassword(@Nonnull final String username,
            @Nonnull final String password); Account getAccount(@Nonnull String userId); @Override void insertAccount(@Nonnull final Account account); @Override void updateAccount(@Nonnull final Account account); @Override void insertProfile(@Nonnull final Account account); @Override void insertSignon(@Nonnull final Account account); @Override void updateProfile(@Nonnull final Account account); void updateSignon(@Nonnull final Account account); }
AccountBasePersistence extends AbstractBasePersistence<Account, String> implements AccountMapper { public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { Account result = null; Query query = createNamedQuery("Account.getAccountByUsernameAndPassword"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); checkState(accounts.size() <= 1, String.format("Query[Account" + ".getAccountByUsernameAndPassword] with parameters[%s,%s] returned [%d] results", username, password, accounts.size())); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }  Account getAccountByUsername(@Nonnull final String username); Account getAccountByUsernameAndPassword(@Nonnull final String username,
            @Nonnull final String password); Account getAccount(@Nonnull String userId); @Override void insertAccount(@Nonnull final Account account); @Override void updateAccount(@Nonnull final Account account); @Override void insertProfile(@Nonnull final Account account); @Override void insertSignon(@Nonnull final Account account); @Override void updateProfile(@Nonnull final Account account); void updateSignon(@Nonnull final Account account);  }