aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java13
1 files changed, 7 insertions, 6 deletions
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<User> query = entityManager.createQuery(
+ "SELECT x FROM User x WHERE x.login = :login", User.class);
+ query.setParameter("login", login);
+ List<User> results = query.getResultList();
+
entityManager.getTransaction().begin();
try {
- String login = user.getLogin();
- TypedQuery<User> query = entityManager.createQuery(
- "SELECT x FROM User x WHERE x.login = :login", User.class);
- query.setParameter("login", login);
- List<User> results = query.getResultList();
-
if (results.isEmpty()) {
entityManager.persist(user);
entityManager.getTransaction().commit();