mirror of
https://github.com/traccar/traccar-web.git
synced 2025-01-09 04:37:33 +08:00
Update DataServiceImpl.java
This commit is contained in:
parent
6a30460996
commit
f8bc5fb042
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user