@Test public void getAccountByUsernameAndPassword_shouldFindExistingAccount() { insertExistingAccount(); Account account = persistence.getAccountByUsernameAndPassword( existingAccount.getUsername(), existingAccount.getPassword()); assertHaveSamePersistentFields(existingAccount, account); }
public Account getAccountByUsernameAndPassword(@Nonnull final String username, @Nonnull final String password) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); checkNotNull(emptyToNull(password), "Argument[password] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery( "select a from Account a where a.username = :username and a.password = :password"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); closeEntityManager(); 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) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); checkNotNull(emptyToNull(password), "Argument[password] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery( "select a from Account a where a.username = :username and a.password = :password"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); closeEntityManager(); 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) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); checkNotNull(emptyToNull(password), "Argument[password] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery( "select a from Account a where a.username = :username and a.password = :password"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); closeEntityManager(); 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) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); checkNotNull(emptyToNull(password), "Argument[password] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery( "select a from Account a where a.username = :username and a.password = :password"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); closeEntityManager(); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }  void deleteAccount(@Nonnull final String username); Account getAccountByUsername(@Nonnull final String username); Account getAccountByUsernameAndPassword(@Nonnull final String username,
            @Nonnull final String password); Account getAccount(@Nonnull String username); @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) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); checkNotNull(emptyToNull(password), "Argument[password] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery( "select a from Account a where a.username = :username and a.password = :password"); query.setParameter("username", username); query.setParameter("password", password); @SuppressWarnings("unchecked") List<Account> accounts = (List<Account>) query.getResultList(); closeEntityManager(); if (accounts.size() == 1) { result = accounts.get(0); } logger.info("Read account[{}]", result); return result; }  void deleteAccount(@Nonnull final String username); Account getAccountByUsername(@Nonnull final String username); Account getAccountByUsernameAndPassword(@Nonnull final String username,
            @Nonnull final String password); Account getAccount(@Nonnull String username); @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);  }