From f8bc5fb042fb2477ea159fc359fdc06b493f0f3e Mon Sep 17 00:00:00 2001 From: Khurshid Fayzullaev Date: Thu, 10 Apr 2014 15:32:04 -0400 Subject: Update DataServiceImpl.java --- src/org/traccar/web/server/model/DataServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/org/traccar/web') diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java index 9706eb1b..cc0b30e0 100644 --- a/src/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/org/traccar/web/server/model/DataServiceImpl.java @@ -191,14 +191,15 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService if (currentUser.getAdmin()) { EntityManager entityManager = getSessionEntityManager(); synchronized (entityManager) { + + String login = user.getLogin(); + TypedQuery query = entityManager.createQuery( + "SELECT x FROM User x WHERE x.login = :login", User.class); + query.setParameter("login", login); + List results = query.getResultList(); + entityManager.getTransaction().begin(); try { - String login = user.getLogin(); - TypedQuery query = entityManager.createQuery( - "SELECT x FROM User x WHERE x.login = :login", User.class); - query.setParameter("login", login); - List results = query.getResultList(); - if (results.isEmpty()) { entityManager.persist(user); entityManager.getTransaction().commit(); -- cgit v1.2.3