You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/09/27 13:06:07 UTC

[2/2] syncope git commit: [SYNCOPE-1214] Manage difference between Any's field and column name

[SYNCOPE-1214] Manage difference between Any's field and column name


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

Branch: refs/heads/master
Commit: 4fe8d084a6aa51fbf7fbfbf025b100df162bd27a
Parents: 79f96cd
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Sep 27 15:05:44 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Sep 27 15:05:56 2017 +0200

----------------------------------------------------------------------
 .../core/persistence/jpa/dao/JPAAnySearchDAO.java        | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/4fe8d084/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index b6d37e6..0f0df60 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.core.persistence.jpa.dao;
 
-import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
@@ -276,8 +275,8 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
         return orderBy;
     }
 
-    private OrderBySupport parseOrderBy(final AnyTypeKind kind, final SearchSupport svs,
-            final List<OrderByClause> orderByClauses) {
+    private OrderBySupport parseOrderBy(
+            final AnyTypeKind kind, final SearchSupport svs, final List<OrderByClause> orderByClauses) {
 
         AnyUtils attrUtils = anyUtilsFactory.getInstance(kind);
 
@@ -289,8 +288,7 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
             // Manage difference among external key attribute and internal JPA @Id
             String fieldName = "key".equals(clause.getField()) ? "id" : clause.getField();
 
-            Field anyField = ReflectionUtils.findField(attrUtils.anyClass(), fieldName);
-            if (anyField == null) {
+            if (ReflectionUtils.findField(attrUtils.anyClass(), fieldName) == null) {
                 PlainSchema schema = schemaDAO.find(fieldName);
                 if (schema != null) {
                     // keep track of involvement of non-mandatory schemas in the order by clauses
@@ -319,6 +317,9 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
                     }
                 }
             } else {
+                // Adjust field name to column name
+                fieldName = "realm".equals(fieldName) ? "realm_id" : fieldName;
+
                 obs.views.add(svs.field());
 
                 item.select = svs.field().alias + "." + fieldName;