Skip to content

Commit

Permalink
Fixing deperecated warning from Hibernate when using alternative DAO
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsavoie authored and ctomc committed Jul 13, 2017
1 parent 0c0ac54 commit 21deb1c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ public class EJBUserDao implements UserDao {
@Inject
private EntityManager entityManager;

@Override
public User getForUsername(String username) {
try {
Query query = entityManager.createQuery("select u from User u where u.username = ?");
query.setParameter(1, username);
Query query = entityManager.createQuery("select u from User u where u.username = :username");
query.setParameter("username", username);
return (User) query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}

@Override
public void createUser(User user) {
entityManager.persist(user);
}
Expand Down

0 comments on commit 21deb1c

Please sign in to comment.