@Test public void getAccountByUsername_shouldReturnNullForNonExistingAccount() { Account account = persistence.getAccountByUsername("non_existing_username"); assertThat(account, nullValue()); }
public Account getAccountByUsername(@Nonnull final String username) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery("select a from Account a where a.username = :username"); query.setParameter("username", username); @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 getAccountByUsername(@Nonnull final String username) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery("select a from Account a where a.username = :username"); query.setParameter("username", username); @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 getAccountByUsername(@Nonnull final String username) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery("select a from Account a where a.username = :username"); query.setParameter("username", username); @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 getAccountByUsername(@Nonnull final String username) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery("select a from Account a where a.username = :username"); query.setParameter("username", username); @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 getAccountByUsername(@Nonnull final String username) { checkNotNull(emptyToNull(username), "Argument[username] must not be empty or null"); Account result = null; Query query = getEntityManager().createQuery("select a from Account a where a.username = :username"); query.setParameter("username", username); @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);  }