syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject syncope git commit: [SYNCOPE-973] Using EntityManager#find for UserDAO#find and RoleDAO#find
Date Fri, 25 Nov 2016 11:43:14 GMT
Repository: syncope
Updated Branches:
  refs/heads/1_2_X 4adf879d3 -> a2316a839


[SYNCOPE-973] Using EntityManager#find for UserDAO#find and RoleDAO#find


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/a2316a83
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/a2316a83
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/a2316a83

Branch: refs/heads/1_2_X
Commit: a2316a839d129792c0160e407c2032bb02cfff8e
Parents: 4adf879
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Nov 25 12:43:05 2016 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Nov 25 12:43:05 2016 +0100

----------------------------------------------------------------------
 .../core/persistence/dao/impl/RoleDAOImpl.java        | 14 +-------------
 .../core/persistence/dao/impl/UserDAOImpl.java        | 13 +------------
 2 files changed, 2 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/a2316a83/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/RoleDAOImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/RoleDAOImpl.java
b/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/RoleDAOImpl.java
index 1a3a889..15d4a7a 100644
--- a/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/RoleDAOImpl.java
+++ b/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/RoleDAOImpl.java
@@ -24,7 +24,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import javax.persistence.TypedQuery;
 
@@ -95,18 +94,7 @@ public class RoleDAOImpl extends AbstractSubjectDAOImpl implements RoleDAO
{
 
     @Override
     public SyncopeRole find(final Long id) {
-        TypedQuery<SyncopeRole> query = entityManager.createQuery("SELECT e FROM SyncopeRole
e WHERE e.id = :id",
-                SyncopeRole.class);
-        query.setParameter("id", id);
-
-        SyncopeRole result = null;
-        try {
-            result = query.getSingleResult();
-        } catch (NoResultException e) {
-            LOG.debug("No role found with id {}", id, e);
-        }
-
-        return result;
+        return entityManager.find(SyncopeRole.class, id);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/a2316a83/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
b/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
index 3d9d630..f6ada46 100644
--- a/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
+++ b/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java
@@ -62,18 +62,7 @@ public class UserDAOImpl extends AbstractSubjectDAOImpl implements UserDAO
{
 
     @Override
     public SyncopeUser find(final Long id) {
-        TypedQuery<SyncopeUser> query = entityManager.createQuery(
-                "SELECT e FROM " + SyncopeUser.class.getSimpleName() + " e WHERE e.id = :id",
SyncopeUser.class);
-        query.setParameter("id", id);
-
-        SyncopeUser result = null;
-        try {
-            result = query.getSingleResult();
-        } catch (NoResultException e) {
-            LOG.debug("No user found with id {}", id, e);
-        }
-
-        return result;
+        return entityManager.find(SyncopeUser.class, id);
     }
 
     @Override


Mime
View raw message