From 21deb1cb8a8660d6cfccab89cbd48a12f5bc3c7c Mon Sep 17 00:00:00 2001 From: Emmanuel Hugonnet Date: Fri, 7 Jul 2017 15:01:24 +0200 Subject: [PATCH] Fixing deperecated warning from Hibernate when using alternative DAO --- .../org/jboss/as/quickstarts/greeter/domain/EJBUserDao.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/greeter/src/main/java/org/jboss/as/quickstarts/greeter/domain/EJBUserDao.java b/greeter/src/main/java/org/jboss/as/quickstarts/greeter/domain/EJBUserDao.java index bea65502bd..c099adcf03 100644 --- a/greeter/src/main/java/org/jboss/as/quickstarts/greeter/domain/EJBUserDao.java +++ b/greeter/src/main/java/org/jboss/as/quickstarts/greeter/domain/EJBUserDao.java @@ -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); }