syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [6/7] syncope git commit: [SYNCOPE-822] Verified it works on all supported DBMS
Date Thu, 21 Apr 2016 09:56:33 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index d09b765..03c426a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -93,7 +93,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
     @Override
     public A authFind(final String key) {
         if (key == null) {
-            throw new NotFoundException("Null key");
+            throw new NotFoundException("Null id");
         }
 
         A any = find(key);
@@ -133,7 +133,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
 
     private Query findByAttrValueQuery(final String entityName) {
         return entityManager().createQuery("SELECT e FROM " + entityName + " e"
-                + " WHERE e.attribute.schema.key = :schemaKey AND (e.stringValue IS NOT NULL"
+                + " WHERE e.attribute.schema.id = :schemaKey AND (e.stringValue IS NOT NULL"
                 + " AND e.stringValue = :stringValue)"
                 + " OR (e.booleanValue IS NOT NULL AND e.booleanValue = :booleanValue)"
                 + " OR (e.dateValue IS NOT NULL AND e.dateValue = :dateValue)"
@@ -294,8 +294,8 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
                 // verify schema existence and get schema type
                 PlainSchema schema = plainSchemaDAO.find(identifiers.get(i));
                 if (schema == null) {
-                    LOG.error("Invalid schema key '{}'", identifiers.get(i));
-                    throw new IllegalArgumentException("Invalid schema key " + identifiers.get(i));
+                    LOG.error("Invalid schema id '{}'", identifiers.get(i));
+                    throw new IllegalArgumentException("Invalid schema id " + identifiers.get(i));
                 }
 
                 // clear builder
@@ -304,13 +304,13 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
                 bld.append("(");
 
                 // set schema name
-                bld.append("s.key = '").append(identifiers.get(i)).append("'");
+                bld.append("s.id = '").append(identifiers.get(i)).append("'");
 
                 bld.append(" AND ");
 
-                bld.append("s.key = a.schema_key").append(" AND ");
+                bld.append("s.id = a.schema_id").append(" AND ");
 
-                bld.append("a.key = v.attribute_key");
+                bld.append("a.id = v.attribute_id");
 
                 bld.append(" AND ");
 
@@ -360,10 +360,10 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
         for (String clause : getWhereClause(schema.getExpression(), value)) {
             if (querystring.length() > 0) {
                 subquery = true;
-                querystring.append(" AND a.owner_key IN ( ");
+                querystring.append(" AND a.owner_id IN ( ");
             }
 
-            querystring.append("SELECT a.owner_key ").
+            querystring.append("SELECT a.owner_id ").
                     append("FROM ").append(getAnyUtils().plainAttrClass().getSimpleName().substring(3)).append(" a, ").
                     append(getAnyUtils().plainAttrValueClass().getSimpleName().substring(3)).append(" v, ").
                     append(PlainSchema.class.getSimpleName()).append(" s ").
@@ -405,7 +405,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A> im
 
     private SearchCond getAllMatchingCond() {
         AnyCond idCond = new AnyCond(AttributeCond.Type.ISNOTNULL);
-        idCond.setSchema("key");
+        idCond.setSchema("id");
         return SearchCond.getLeafCond(idCond);
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/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 9504360..85aaddc 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
@@ -74,7 +74,7 @@ import org.springframework.util.ReflectionUtils;
 @Repository
 public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO {
 
-    private static final String EMPTY_QUERY = "SELECT any_key FROM user_search_attr WHERE 1=2";
+    private static final String EMPTY_QUERY = "SELECT any_id FROM user_search_attr WHERE 1=2";
 
     @Autowired
     private RealmDAO realmDAO;
@@ -111,8 +111,8 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
         }
 
         StringBuilder adminRealmFilter = new StringBuilder().
-                append("SELECT any_key FROM ").append(svs.field().name).
-                append(" WHERE realm_key IN (SELECT key AS realm_key FROM Realm");
+                append("SELECT any_id FROM ").append(svs.field().name).
+                append(" WHERE realm_id IN (SELECT id AS realm_id FROM Realm");
 
         boolean firstRealm = true;
         for (String realmKey : realmKeys) {
@@ -122,7 +122,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
             } else {
                 adminRealmFilter.append(" OR");
             }
-            adminRealmFilter.append(" key=?").append(setParameter(parameters, realmKey));
+            adminRealmFilter.append(" id=?").append(setParameter(parameters, realmKey));
         }
 
         adminRealmFilter.append(')');
@@ -139,13 +139,13 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
         StringBuilder queryString = getQuery(searchCondition, parameters, svs);
 
         // 2. take into account administrative realms
-        queryString.insert(0, "SELECT u.any_key FROM (");
-        queryString.append(") u WHERE any_key IN (");
+        queryString.insert(0, "SELECT u.any_id FROM (");
+        queryString.append(") u WHERE any_id IN (");
         queryString.append(getAdminRealmsFilter(adminRealms, svs, parameters)).append(')');
 
         // 3. prepare the COUNT query
-        queryString.insert(0, "SELECT COUNT(any_key) FROM (");
-        queryString.append(") count_any_key");
+        queryString.insert(0, "SELECT COUNT(any_id) FROM (");
+        queryString.append(") count_any_id");
 
         Query countQuery = entityManager().createNativeQuery(queryString.toString());
         fillWithParameters(countQuery, parameters);
@@ -213,8 +213,8 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
             matches = false;
         } else {
             // 2. take into account the passed user
-            queryString.insert(0, "SELECT u.any_key FROM (");
-            queryString.append(") u WHERE any_key=?").append(setParameter(parameters, any.getKey()));
+            queryString.insert(0, "SELECT u.any_id FROM (");
+            queryString.append(") u WHERE any_id=?").append(setParameter(parameters, any.getKey()));
 
             // 3. prepare the search query
             Query query = entityManager().createNativeQuery(queryString.toString());
@@ -254,7 +254,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     }
 
     private StringBuilder buildSelect(final OrderBySupport orderBySupport) {
-        final StringBuilder select = new StringBuilder("SELECT u.any_key");
+        final StringBuilder select = new StringBuilder("SELECT u.any_id");
 
         for (OrderBySupport.Item obs : orderBySupport.items) {
             select.append(',').append(obs.select);
@@ -279,7 +279,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
         }
         where.append(" WHERE ");
         for (SearchSupport.SearchView searchView : orderBySupport.views) {
-            where.append("u.any_key=").append(searchView.alias).append(".any_key AND ");
+            where.append("u.any_id=").append(searchView.alias).append(".any_id AND ");
         }
 
         for (OrderBySupport.Item obs : orderBySupport.items) {
@@ -287,7 +287,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
                 where.append(obs.where).append(" AND ");
             }
         }
-        where.append("u.any_key IN (");
+        where.append("u.any_id IN (");
 
         return where;
     }
@@ -316,7 +316,8 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
         for (OrderByClause clause : orderByClauses) {
             OrderBySupport.Item obs = new OrderBySupport.Item();
 
-            String fieldName = clause.getField();
+            // 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) {
@@ -330,7 +331,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
                                 append(" AS ").append(fieldName).toString();
                         obs.where = new StringBuilder().
                                 append(svs.uniqueAttr().alias).
-                                append(".schema_key='").append(fieldName).append("'").toString();
+                                append(".schema_id='").append(fieldName).append("'").toString();
                         obs.orderBy = fieldName + " " + clause.getDirection().name();
                     } else {
                         orderBySupport.views.add(svs.attr());
@@ -340,7 +341,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
                                 append(" AS ").append(fieldName).toString();
                         obs.where = new StringBuilder().
                                 append(svs.attr().alias).
-                                append(".schema_key='").append(fieldName).append("'").toString();
+                                append(".schema_id='").append(fieldName).append("'").toString();
                         obs.orderBy = fieldName + " " + clause.getDirection().name();
                     }
                 }
@@ -413,7 +414,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
                             ? (T) groupDAO.find(actualKey)
                             : (T) anyObjectDAO.find(actualKey);
             if (any == null) {
-                LOG.error("Could not find {} with key {}, even though returned by the native query",
+                LOG.error("Could not find {} with id {}, even though returned by the native query",
                         typeKind, actualKey);
             } else if (!result.contains(any)) {
                 result.add(any);
@@ -467,14 +468,14 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
 
             case AND:
                 query.append(getQuery(nodeCond.getLeftNodeCond(), parameters, svs)).
-                        append(" AND any_key IN ( ").
+                        append(" AND any_id IN ( ").
                         append(getQuery(nodeCond.getRightNodeCond(), parameters, svs)).
                         append(")");
                 break;
 
             case OR:
                 query.append(getQuery(nodeCond.getLeftNodeCond(), parameters, svs)).
-                        append(" OR any_key IN ( ").
+                        append(" OR any_id IN ( ").
                         append(getQuery(nodeCond.getRightNodeCond(), parameters, svs)).
                         append(")");
                 break;
@@ -488,8 +489,8 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final AnyTypeCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
-                append(svs.field().name).append(" WHERE type_key");
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
+                append(svs.field().name).append(" WHERE type_id");
 
         if (not) {
             query.append("<>");
@@ -505,19 +506,19 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final RelationshipTypeCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         if (not) {
-            query.append("any_key NOT IN (");
+            query.append("any_id NOT IN (");
         } else {
-            query.append("any_key IN (");
+            query.append("any_id IN (");
         }
 
-        query.append("SELECT any_key ").append("FROM ").
+        query.append("SELECT any_id ").append("FROM ").
                 append(svs.relationship().name).
                 append(" WHERE type=?").append(setParameter(parameters, cond.getRelationshipTypeKey())).
-                append(" UNION SELECT right_any_key AS any_key FROM ").
+                append(" UNION SELECT right_any_id AS any_id FROM ").
                 append(svs.relationship().name).
                 append(" WHERE type=?").append(setParameter(parameters, cond.getRelationshipTypeKey())).
                 append(')');
@@ -528,18 +529,18 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final RelationshipCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         if (not) {
-            query.append("any_key NOT IN (");
+            query.append("any_id NOT IN (");
         } else {
-            query.append("any_key IN (");
+            query.append("any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key ").append("FROM ").
+        query.append("SELECT DISTINCT any_id ").append("FROM ").
                 append(svs.relationship().name).append(" WHERE ").
-                append("right_any_key=?").append(setParameter(parameters, cond.getAnyObjectKey())).
+                append("right_any_id=?").append(setParameter(parameters, cond.getAnyObjectKey())).
                 append(')');
 
         return query.toString();
@@ -548,29 +549,29 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final MembershipCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         if (not) {
-            query.append("any_key NOT IN (");
+            query.append("any_id NOT IN (");
         } else {
-            query.append("any_key IN (");
+            query.append("any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key ").append("FROM ").
+        query.append("SELECT DISTINCT any_id ").append("FROM ").
                 append(svs.membership().name).append(" WHERE ").
-                append("group_key=?").append(setParameter(parameters, cond.getGroupKey())).
+                append("group_id=?").append(setParameter(parameters, cond.getGroupKey())).
                 append(')');
 
         if (not) {
-            query.append("AND any_key NOT IN (");
+            query.append("AND any_id NOT IN (");
         } else {
-            query.append("OR any_key IN (");
+            query.append("OR any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key ").append("FROM ").
+        query.append("SELECT DISTINCT any_id ").append("FROM ").
                 append(svs.dyngroupmembership().name).append(" WHERE ").
-                append("group_key=?").append(setParameter(parameters, cond.getGroupKey())).
+                append("group_id=?").append(setParameter(parameters, cond.getGroupKey())).
                 append(')');
 
         return query.toString();
@@ -579,29 +580,29 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final RoleCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         if (not) {
-            query.append("any_key NOT IN (");
+            query.append("any_id NOT IN (");
         } else {
-            query.append("any_key IN (");
+            query.append("any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key ").append("FROM ").
+        query.append("SELECT DISTINCT any_id ").append("FROM ").
                 append(svs.role().name).append(" WHERE ").
-                append("role_key=?").append(setParameter(parameters, cond.getRoleKey())).
+                append("role_id=?").append(setParameter(parameters, cond.getRoleKey())).
                 append(')');
 
         if (not) {
-            query.append("AND any_key NOT IN (");
+            query.append("AND any_id NOT IN (");
         } else {
-            query.append("OR any_key IN (");
+            query.append("OR any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key ").append("FROM ").
+        query.append("SELECT DISTINCT any_id ").append("FROM ").
                 append(svs.dynrolemembership().name).append(" WHERE ").
-                append("role_key=?").append(setParameter(parameters, cond.getRoleKey())).
+                append("role_id=?").append(setParameter(parameters, cond.getRoleKey())).
                 append(')');
 
         return query.toString();
@@ -610,24 +611,24 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
     private String getQuery(final ResourceCond cond, final boolean not, final List<Object> parameters,
             final SearchSupport svs) {
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         if (not) {
-            query.append("any_key NOT IN (");
+            query.append("any_id NOT IN (");
         } else {
-            query.append("any_key IN (");
+            query.append("any_id IN (");
         }
 
-        query.append("SELECT DISTINCT any_key FROM ").
+        query.append("SELECT DISTINCT any_id FROM ").
                 append(svs.resource().name).
-                append(" WHERE resource_key=?").
+                append(" WHERE resource_id=?").
                 append(setParameter(parameters, cond.getResourceKey()));
 
         if (svs.anyTypeKind() == AnyTypeKind.USER) {
-            query.append(" UNION SELECT DISTINCT any_key FROM ").
+            query.append(" UNION SELECT DISTINCT any_id FROM ").
                     append(svs.groupResource().name).
-                    append(" WHERE resource_key=?").
+                    append(" WHERE resource_id=?").
                     append(setParameter(parameters, cond.getResourceKey()));
         }
 
@@ -642,16 +643,16 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
             return EMPTY_QUERY;
         }
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE (");
         if (cond.isFromGroup()) {
             for (Realm current = realm; current.getParent() != null; current = current.getParent()) {
-                query.append("realm_key=?").append(setParameter(parameters, current.getKey())).append(" OR ");
+                query.append("realm_id=?").append(setParameter(parameters, current.getKey())).append(" OR ");
             }
-            query.append("realm_key=?").append(setParameter(parameters, realmDAO.getRoot().getKey()));
+            query.append("realm_id=?").append(setParameter(parameters, realmDAO.getRoot().getKey()));
         } else {
             for (Realm current : realmDAO.findDescendants(realm)) {
-                query.append("realm_key=?").append(setParameter(parameters, current.getKey())).append(" OR ");
+                query.append("realm_id=?").append(setParameter(parameters, current.getKey())).append(" OR ");
             }
             query.setLength(query.length() - 4);
         }
@@ -775,18 +776,18 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
             return EMPTY_QUERY;
         }
 
-        StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ");
+        StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ");
         switch (cond.getType()) {
             case ISNOTNULL:
                 query.append(svs.field().name).
-                        append(" WHERE any_key NOT IN (SELECT any_key FROM ").
+                        append(" WHERE any_id NOT IN (SELECT any_id FROM ").
                         append(svs.nullAttr().name).
-                        append(" WHERE schema_key='").append(schema.getKey()).append("')");
+                        append(" WHERE schema_id='").append(schema.getKey()).append("')");
                 break;
 
             case ISNULL:
                 query.append(svs.nullAttr().name).
-                        append(" WHERE schema_key='").append(schema.getKey()).append("'");
+                        append(" WHERE schema_id='").append(schema.getKey()).append("'");
                 break;
 
             default:
@@ -795,7 +796,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
                 } else {
                     query.append(svs.attr().name);
                 }
-                query.append(" WHERE schema_key='").append(schema.getKey());
+                query.append(" WHERE schema_id='").append(schema.getKey());
                 fillAttributeQuery(query, attrValue, schema, cond, not, parameters, svs);
         }
 
@@ -808,6 +809,11 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
 
         AnyUtils attrUtils = anyUtilsFactory.getInstance(svs.anyTypeKind());
 
+        // Keeps track of difference between entity's getKey() and JPA @Id fields
+        if ("key".equals(cond.getSchema())) {
+            cond.setSchema("id");
+        }
+
         Field anyField = ReflectionUtils.findField(attrUtils.anyClass(), cond.getSchema());
         if (anyField == null) {
             LOG.warn("Ignoring invalid schema '{}'", cond.getSchema());
@@ -849,11 +855,11 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
 
             if (relMethod != null) {
                 if (Long.class.isAssignableFrom(relMethod.getReturnType())) {
-                    cond.setSchema(cond.getSchema() + "_key");
+                    cond.setSchema(cond.getSchema() + "_id");
                     schema.setType(AttrSchemaType.Long);
                 }
                 if (String.class.isAssignableFrom(relMethod.getReturnType())) {
-                    cond.setSchema(cond.getSchema() + "_key");
+                    cond.setSchema(cond.getSchema() + "_id");
                     schema.setType(AttrSchemaType.String);
                 }
             }
@@ -872,7 +878,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>> implements AnySearchDAO
             }
         }
 
-        final StringBuilder query = new StringBuilder("SELECT DISTINCT any_key FROM ").
+        final StringBuilder query = new StringBuilder("SELECT DISTINCT any_id FROM ").
                 append(svs.field().name).append(" WHERE ");
 
         fillAttributeQuery(query, attrValue, schema, cond, not, parameters, svs);

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
index f8add11..3cce4b5 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
@@ -49,7 +49,7 @@ public class JPADerSchemaDAO extends AbstractDAO<DerSchema> implements DerSchema
                 append(JPADerSchema.class.getSimpleName()).
                 append(" e WHERE ");
         for (AnyTypeClass anyTypeClass : anyTypeClasses) {
-            queryString.append("e.anyTypeClass.key='").append(anyTypeClass.getKey()).append("' OR ");
+            queryString.append("e.anyTypeClass.id='").append(anyTypeClass.getKey()).append("' OR ");
         }
 
         TypedQuery<DerSchema> query = entityManager().createQuery(

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
index 3ec6d5a..38d4add 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAGroupDAO.java
@@ -158,7 +158,7 @@ public class JPAGroupDAO extends AbstractAnyDAO<Group> implements GroupDAO {
         StringBuilder queryString = new StringBuilder("SELECT e FROM ").append(JPAGroup.class.getSimpleName()).
                 append(" e WHERE e.userOwner=:owner ");
         for (String groupKey : userDAO.findAllGroupKeys(owner)) {
-            queryString.append("OR e.groupOwner.key='").append(groupKey).append("' ");
+            queryString.append("OR e.groupOwner.id='").append(groupKey).append("' ");
         }
 
         TypedQuery<Group> query = entityManager().createQuery(queryString.toString(), Group.class);

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
index 5b79d53..1b88c82 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
@@ -55,7 +55,7 @@ public class JPAPlainSchemaDAO extends AbstractDAO<PlainSchema> implements Plain
                 append(JPAPlainSchema.class.getSimpleName()).
                 append(" e WHERE ");
         for (AnyTypeClass anyTypeClass : anyTypeClasses) {
-            queryString.append("e.anyTypeClass.key='").append(anyTypeClass.getKey()).append("' OR ");
+            queryString.append("e.anyTypeClass.id='").append(anyTypeClass.getKey()).append("' OR ");
         }
 
         TypedQuery<PlainSchema> query = entityManager().createQuery(

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java
index 414a171..ae62461 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskDAO.java
@@ -87,9 +87,11 @@ public class JPATaskDAO extends AbstractDAO<Task> implements TaskDAO {
                 append(getEntityReference(type).getSimpleName()).
                 append(" t WHERE ");
         if (type == TaskType.SCHEDULED) {
-            builder.append("t.key NOT IN (SELECT t.key FROM ").append(JPAPushTask.class.getSimpleName()).append(" t) ").
+            builder.append("t.id NOT IN (SELECT t.id FROM ").
+                    append(JPAPushTask.class.getSimpleName()).append(" t) ").
                     append("AND ").
-                    append("t.key NOT IN (SELECT t.key FROM ").append(JPAPullTask.class.getSimpleName()).append(" t)");
+                    append("t.id NOT IN (SELECT t.id FROM ").
+                    append(JPAPullTask.class.getSimpleName()).append(" t)");
         } else {
             builder.append("1=1");
         }
@@ -107,7 +109,7 @@ public class JPATaskDAO extends AbstractDAO<Task> implements TaskDAO {
         } else {
             queryString.append("t.executions IS EMPTY ");
         }
-        queryString.append("ORDER BY t.key DESC");
+        queryString.append("ORDER BY t.id DESC");
 
         Query query = entityManager().createQuery(queryString.toString());
         return query.getResultList();
@@ -168,7 +170,7 @@ public class JPATaskDAO extends AbstractDAO<Task> implements TaskDAO {
         }
 
         if (statement.length() == 0) {
-            statement.append("ORDER BY t.key DESC");
+            statement.append("ORDER BY t.id DESC");
         } else {
             statement.insert(0, "ORDER BY ");
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java
index e4c97a6..531cb4b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPATaskExecDAO.java
@@ -119,7 +119,7 @@ public class JPATaskExecDAO extends AbstractDAO<TaskExec> implements TaskExecDAO
     @Override
     public int count(final String taskKey) {
         Query countQuery = entityManager().createNativeQuery(
-                "SELECT COUNT(e.key) FROM " + JPATaskExec.TABLE + " e WHERE e.task_key=?1");
+                "SELECT COUNT(e.id) FROM " + JPATaskExec.TABLE + " e WHERE e.task_id=?1");
         countQuery.setParameter(1, taskKey);
 
         return ((Number) countQuery.getSingleResult()).intValue();
@@ -136,7 +136,7 @@ public class JPATaskExecDAO extends AbstractDAO<TaskExec> implements TaskExecDAO
         }
 
         if (statement.length() == 0) {
-            statement.append("ORDER BY e.key DESC");
+            statement.append("ORDER BY e.id DESC");
         } else {
             statement.insert(0, "ORDER BY ");
         }

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
index 2643861..9a42b17 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
@@ -51,7 +51,7 @@ public class JPAVirSchemaDAO extends AbstractDAO<VirSchema> implements VirSchema
                 append(JPAVirSchema.class.getSimpleName()).
                 append(" e WHERE ");
         for (AnyTypeClass anyTypeClass : anyTypeClasses) {
-            queryString.append("e.anyTypeClass.key='").append(anyTypeClass.getKey()).append("' OR ");
+            queryString.append("e.anyTypeClass.id='").append(anyTypeClass.getKey()).append("' OR ");
         }
 
         TypedQuery<VirSchema> query = entityManager().createQuery(

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractGeneratedKeyEntity.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractGeneratedKeyEntity.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractGeneratedKeyEntity.java
index c3924c8..c642ea3 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractGeneratedKeyEntity.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractGeneratedKeyEntity.java
@@ -32,11 +32,11 @@ public abstract class AbstractGeneratedKeyEntity extends AbstractEntity {
     @Id
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "uuid")
     @Column(length = 36)
-    private String key;
+    private String id;
 
     @Override
     public String getKey() {
-        return key;
+        return id;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
index 5c95118..d647854 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractPlainAttr.java
@@ -44,7 +44,7 @@ public abstract class AbstractPlainAttr<O extends Any<?>> extends AbstractGenera
 
     @NotNull
     @ManyToOne(fetch = FetchType.EAGER)
-    @Column(name = "schema_key")
+    @Column(name = "schema_id")
     protected JPAPlainSchema schema;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractProvidedKeyEntity.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractProvidedKeyEntity.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractProvidedKeyEntity.java
index 49b6713..3709584 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractProvidedKeyEntity.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/AbstractProvidedKeyEntity.java
@@ -28,16 +28,16 @@ public abstract class AbstractProvidedKeyEntity extends AbstractEntity implement
     private static final long serialVersionUID = 821537874069666593L;
 
     @Id
-    private String key;
+    private String id;
 
     @Override
     public String getKey() {
-        return key;
+        return id;
     }
 
     @Override
     public void setKey(final String key) {
-        this.key = key;
+        this.id = key;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyAbout.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyAbout.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyAbout.java
index 3839be5..3806b8c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyAbout.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyAbout.java
@@ -29,7 +29,7 @@ import org.apache.syncope.core.persistence.api.entity.Notification;
 
 @Entity
 @Table(name = JPAAnyAbout.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "notification_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "notification_id", "anyType_id" }))
 public class JPAAnyAbout extends AbstractGeneratedKeyEntity implements AnyAbout {
 
     private static final long serialVersionUID = 3517381731849788407L;

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTemplateRealm.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTemplateRealm.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTemplateRealm.java
index 911eeaf..46949ee 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTemplateRealm.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyTemplateRealm.java
@@ -28,7 +28,7 @@ import org.apache.syncope.core.persistence.jpa.entity.resource.AbstractAnyTempla
 
 @Entity
 @Table(name = JPAAnyTemplateRealm.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "realm_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "realm_id", "anyType_id" }))
 public class JPAAnyTemplateRealm extends AbstractAnyTemplate implements AnyTemplateRealm {
 
     public static final String TABLE = "AnyTemplateRealm";

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
index 272716c..d9025bc 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAAnyType.java
@@ -51,9 +51,9 @@ public class JPAAnyType extends AbstractProvidedKeyEntity implements AnyType {
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "anyType_key", referencedColumnName = "key"),
+            @JoinColumn(name = "anyType_id", referencedColumnName = "id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key", referencedColumnName = "key"))
+            @JoinColumn(name = "anyTypeClass_id", referencedColumnName = "id"))
     private List<JPAAnyTypeClass> classes = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java
index a059354..facb93f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAConnInstance.java
@@ -95,7 +95,7 @@ public class JPAConnInstance extends AbstractGeneratedKeyEntity implements ConnI
     @Column(name = "capability")
     @CollectionTable(name = "ConnInstance_capabilities",
             joinColumns =
-            @JoinColumn(name = "connInstance_key", referencedColumnName = "key"))
+            @JoinColumn(name = "connInstance_id", referencedColumnName = "id"))
     private Set<ConnectorCapability> capabilities = new HashSet<>();
 
     /**

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java
index 73ce78f..7d186cd 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPANotification.java
@@ -59,7 +59,7 @@ public class JPANotification extends AbstractGeneratedKeyEntity implements Notif
     @Column(name = "event")
     @CollectionTable(name = "Notification_events",
             joinColumns =
-            @JoinColumn(name = "notification_key", referencedColumnName = "key"))
+            @JoinColumn(name = "notification_id", referencedColumnName = "id"))
     private List<String> events;
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "notification")
@@ -70,7 +70,7 @@ public class JPANotification extends AbstractGeneratedKeyEntity implements Notif
     @ElementCollection(fetch = FetchType.EAGER)
     @CollectionTable(name = "Notification_staticRecipients",
             joinColumns =
-            @JoinColumn(name = "notification_key", referencedColumnName = "key"))
+            @JoinColumn(name = "notification_id", referencedColumnName = "id"))
     @Column(name = "staticRecipients")
     private List<String> staticRecipients;
 
@@ -96,7 +96,7 @@ public class JPANotification extends AbstractGeneratedKeyEntity implements Notif
     private String subject;
 
     @ManyToOne(fetch = FetchType.EAGER, optional = false)
-    @JoinColumn(name = "template_key")
+    @JoinColumn(name = "template_id")
     private JPAMailTemplate template;
 
     @NotNull

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
index 719f9a8..681ce8e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARealm.java
@@ -51,7 +51,7 @@ import org.apache.syncope.core.persistence.jpa.validation.entity.RealmCheck;
 
 @Entity
 @Table(name = JPARealm.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "key", "parent_key" }))
+        @UniqueConstraint(columnNames = { "id", "parent_id" }))
 @Cacheable
 @RealmCheck
 public class JPARealm extends AbstractGeneratedKeyEntity implements Realm {
@@ -76,7 +76,7 @@ public class JPARealm extends AbstractGeneratedKeyEntity implements Realm {
     @Column(name = "actionClassName")
     @CollectionTable(name = "Realm_actionsClassNames",
             joinColumns =
-            @JoinColumn(name = "realm_key", referencedColumnName = "key"))
+            @JoinColumn(name = "realm_key", referencedColumnName = "id"))
     private Set<String> actionsClassNames = new HashSet<>();
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "realm")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAReport.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAReport.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAReport.java
index cb9e029..73606cc 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAReport.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPAReport.java
@@ -67,7 +67,7 @@ public class JPAReport extends AbstractGeneratedKeyEntity implements Report {
     private Integer active;
 
     @ManyToOne(fetch = FetchType.EAGER, optional = false)
-    @JoinColumn(name = "template_key")
+    @JoinColumn(name = "template_id")
     private JPAReportTemplate template;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
index cc8aa68..1b74b98 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
@@ -55,14 +55,14 @@ public class JPARole extends AbstractProvidedKeyEntity implements Role {
     @Column(name = "entitlement")
     @CollectionTable(name = "SyncopeRole_entitlements",
             joinColumns =
-            @JoinColumn(name = "role_key", referencedColumnName = "key"))
+            @JoinColumn(name = "role_id", referencedColumnName = "id"))
     private Set<String> entitlements = new HashSet<>();
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "role_key"),
+            @JoinColumn(name = "role_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "realm_key"))
+            @JoinColumn(name = "realm_id"))
     @Valid
     private List<JPARealm> realms = new ArrayList<>();
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
index b0ca6ea..4bb75fc 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
@@ -51,9 +51,9 @@ public class JPAADynGroupMembership extends AbstractDynMembership<AnyObject> imp
 
     @ManyToMany
     @JoinTable(joinColumns =
-            @JoinColumn(name = "aDynGroupMembership_key"),
+            @JoinColumn(name = "aDynGroupMembership_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyObject_key"))
+            @JoinColumn(name = "anyObject_id"))
     private List<JPAAnyObject> anyObjects = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
index 2d017ba..1561dae 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
@@ -39,11 +39,11 @@ public class JPAAMembership extends AbstractGeneratedKeyEntity implements AMembe
     public static final String TABLE = "AMembership";
 
     @ManyToOne
-    @Column(name = "anyObject_key")
+    @Column(name = "anyObject_id")
     private JPAAnyObject leftEnd;
 
     @ManyToOne
-    @Column(name = "group_key")
+    @Column(name = "group_id")
     private JPAGroup rightEnd;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
index af4d8da..4b0d18e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
@@ -42,7 +42,7 @@ public class JPAAPlainAttrUniqueValue extends AbstractPlainAttrValue implements
     private JPAAPlainAttr attribute;
 
     @ManyToOne(optional = false)
-    @JoinColumn(name = "schema_key")
+    @JoinColumn(name = "schema_id")
     private JPAPlainSchema schema;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
index 49bdd5b..b488538 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
@@ -33,7 +33,7 @@ import org.apache.syncope.core.persistence.jpa.entity.JPARelationshipType;
 
 @Entity
 @Table(name = JPAARelationship.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "type_key", "left_anyObject_key", "right_anyObject_key" }))
+        @UniqueConstraint(columnNames = { "type_id", "left_anyObject_id", "right_anyObject_id" }))
 public class JPAARelationship extends AbstractGeneratedKeyEntity implements ARelationship {
 
     private static final long serialVersionUID = 6608821135023815357L;
@@ -44,11 +44,11 @@ public class JPAARelationship extends AbstractGeneratedKeyEntity implements ARel
     private JPARelationshipType type;
 
     @ManyToOne
-    @Column(name = "left_anyObject_key")
+    @Column(name = "left_anyObject_id")
     private JPAAnyObject leftEnd;
 
     @ManyToOne
-    @Column(name = "right_anyObject_key")
+    @Column(name = "right_anyObject_id")
     private JPAAnyObject rightEnd;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
index deb19d9..44f55df 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
@@ -67,16 +67,16 @@ public class JPAAnyObject extends AbstractAny<APlainAttr> implements AnyObject {
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "anyObject_key"),
+            @JoinColumn(name = "anyObject_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "resource_key"))
+            @JoinColumn(name = "resource_id"))
     private List<JPAExternalResource> resources = new ArrayList<>();
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "anyObject_key"),
+            @JoinColumn(name = "anyObject_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key"))
+            @JoinColumn(name = "anyTypeClass_id"))
     private List<JPAAnyTypeClass> auxClasses = new ArrayList<>();
 
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "leftEnd")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
index 26e7de4..ef447be 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/conf/JPACPlainAttrUniqueValue.java
@@ -42,7 +42,7 @@ public class JPACPlainAttrUniqueValue extends AbstractPlainAttrValue implements
     private JPACPlainAttr attribute;
 
     @ManyToOne(optional = false)
-    @JoinColumn(name = "schema_key")
+    @JoinColumn(name = "schema_id")
     private JPAPlainSchema schema;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
index 49ab347..603f247 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
@@ -42,7 +42,7 @@ public class JPAGPlainAttrUniqueValue extends AbstractPlainAttrValue implements
     private JPAGPlainAttr attribute;
 
     @ManyToOne(optional = false)
-    @JoinColumn(name = "schema_key")
+    @JoinColumn(name = "schema_id")
     private JPAPlainSchema schema;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
index f8acfc7..8afb1ae 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
@@ -80,17 +80,17 @@ public class JPAGroup extends AbstractAny<GPlainAttr> implements Group {
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "group_key"),
+            @JoinColumn(name = "group_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "resource_key"))
+            @JoinColumn(name = "resource_id"))
     @Valid
     private List<JPAExternalResource> resources = new ArrayList<>();
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "group_key"),
+            @JoinColumn(name = "group_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key"))
+            @JoinColumn(name = "anyTypeClass_id"))
     private List<JPAAnyTypeClass> auxClasses = new ArrayList<>();
 
     @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "group")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
index 1d8348f..9ddf68a 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
@@ -38,7 +38,7 @@ import org.apache.syncope.core.persistence.jpa.entity.JPAAnyTypeClass;
 
 @Entity
 @Table(name = JPATypeExtension.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "group_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "group_id", "anyType_id" }))
 public class JPATypeExtension extends AbstractGeneratedKeyEntity implements TypeExtension {
 
     private static final long serialVersionUID = -8367626793791263551L;
@@ -53,9 +53,9 @@ public class JPATypeExtension extends AbstractGeneratedKeyEntity implements Type
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "typeExtension_key"),
+            @JoinColumn(name = "typeExtension_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key"))
+            @JoinColumn(name = "anyTypeClass_id"))
     private List<JPAAnyTypeClass> auxClasses = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccountPolicy.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccountPolicy.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccountPolicy.java
index 237330b..ef0aeb7 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccountPolicy.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/policy/JPAAccountPolicy.java
@@ -64,9 +64,9 @@ public class JPAAccountPolicy extends AbstractPolicy implements AccountPolicy {
      */
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "accountPolicy_key"),
+            @JoinColumn(name = "accountPolicy_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "resource_key"))
+            @JoinColumn(name = "resource_id"))
     private Set<JPAExternalResource> resources = new HashSet<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java
index f4bff24..c93b21c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAExternalResource.java
@@ -149,7 +149,7 @@ public class JPAExternalResource extends AbstractProvidedKeyEntity implements Ex
     @Column(name = "capabilityOverride")
     @CollectionTable(name = "ExternalResource_capOverride",
             joinColumns =
-            @JoinColumn(name = "resource_key", referencedColumnName = "key"))
+            @JoinColumn(name = "resource_id", referencedColumnName = "id"))
     private Set<ConnectorCapability> capabilitiesOverride = new HashSet<>();
 
     /**
@@ -159,7 +159,7 @@ public class JPAExternalResource extends AbstractProvidedKeyEntity implements Ex
     @Column(name = "actionClassName")
     @CollectionTable(name = "ExternalResource_PropActions",
             joinColumns =
-            @JoinColumn(name = "resource_key", referencedColumnName = "key"))
+            @JoinColumn(name = "resource_id", referencedColumnName = "id"))
     private List<String> propagationActionsClassNames = new ArrayList<>();
 
     public JPAExternalResource() {

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java
index ccc53ed..f3d2702 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAMappingItem.java
@@ -73,7 +73,7 @@ public class JPAMappingItem extends AbstractGeneratedKeyEntity implements Mappin
     private String mandatoryCondition;
 
     /**
-     * Specify if the mapped target resource's field is the key.
+     * Specify if the mapped target resource's field is the id.
      */
     @NotNull
     @Basic
@@ -101,7 +101,7 @@ public class JPAMappingItem extends AbstractGeneratedKeyEntity implements Mappin
     @Column(name = "transformerClassName")
     @CollectionTable(name = "MappingItem_Transformer",
             joinColumns =
-            @JoinColumn(name = "mappingItem_key", referencedColumnName = "key"))
+            @JoinColumn(name = "mappingItem_id", referencedColumnName = "id"))
     private List<String> mappingItemTransformerClassNames = new ArrayList<>();
 
     public JPAMappingItem() {
@@ -152,7 +152,7 @@ public class JPAMappingItem extends AbstractGeneratedKeyEntity implements Mappin
             case UserKey:
             case GroupKey:
             case AnyObjectKey:
-                name = "key";
+                name = "id";
                 break;
 
             case Username:

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAProvision.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAProvision.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAProvision.java
index 96ca9a1..5c10f51 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAProvision.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/resource/JPAProvision.java
@@ -46,7 +46,7 @@ import org.identityconnectors.framework.common.objects.SyncToken;
 
 @Entity
 @Table(name = JPAProvision.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "resource_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "resource_id", "anyType_id" }))
 public class JPAProvision extends AbstractGeneratedKeyEntity implements Provision {
 
     private static final long serialVersionUID = -1807889487945989443L;
@@ -64,9 +64,9 @@ public class JPAProvision extends AbstractGeneratedKeyEntity implements Provisio
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "provision_key"),
+            @JoinColumn(name = "provision_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key"))
+            @JoinColumn(name = "anyTypeClass_id"))
     private List<JPAAnyTypeClass> auxClasses = new ArrayList<>();
 
     @Lob

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyTemplatePullTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyTemplatePullTask.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyTemplatePullTask.java
index ce52e9a..3d72642 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyTemplatePullTask.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAAnyTemplatePullTask.java
@@ -28,7 +28,7 @@ import org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask;
 
 @Entity
 @Table(name = JPAAnyTemplatePullTask.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "pullTask_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "pullTask_id", "anyType_id" }))
 public class JPAAnyTemplatePullTask extends AbstractAnyTemplate implements AnyTemplatePullTask {
 
     private static final long serialVersionUID = 3517381731849788407L;

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPANotificationTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPANotificationTask.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPANotificationTask.java
index fe01d78..5db9ed7 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPANotificationTask.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPANotificationTask.java
@@ -60,7 +60,7 @@ public class JPANotificationTask extends AbstractTask implements NotificationTas
     @Column(name = "address")
     @CollectionTable(name = "NotificationTask_recipients",
             joinColumns =
-            @JoinColumn(name = "notificationTask_key", referencedColumnName = "key"))
+            @JoinColumn(name = "notificationTask_id", referencedColumnName = "id"))
     private Set<String> recipients = new HashSet<>();
 
     @NotNull

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPullTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPullTask.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPullTask.java
index 657a2f0..7dca06c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPullTask.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPullTask.java
@@ -64,7 +64,7 @@ public class JPAPullTask extends AbstractProvisioningTask implements PullTask {
     @Column(name = "actionClassName")
     @CollectionTable(name = "PullTask_actionsClassNames",
             joinColumns =
-            @JoinColumn(name = "pullTask_key", referencedColumnName = "key"))
+            @JoinColumn(name = "pullTask_id", referencedColumnName = "id"))
     private Set<String> actionsClassNames = new HashSet<>();
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "pullTask")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
index 41ef5a2..2f558ff 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTask.java
@@ -47,7 +47,7 @@ public class JPAPushTask extends AbstractProvisioningTask implements PushTask {
     @Column(name = "actionClassName")
     @CollectionTable(name = "PushTask_actionsClassNames",
             joinColumns =
-            @JoinColumn(name = "pushTask_key", referencedColumnName = "key"))
+            @JoinColumn(name = "pushTask_key", referencedColumnName = "id"))
     private Set<String> actionsClassNames = new HashSet<>();
 
     @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "pushTask")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
index db237c7..df2f62c 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/task/JPAPushTaskAnyFilter.java
@@ -31,7 +31,7 @@ import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity
 
 @Entity
 @Table(name = JPAPushTaskAnyFilter.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "pushTask_key", "anyType_key" }))
+        @UniqueConstraint(columnNames = { "pushTask_id", "anyType_id" }))
 public class JPAPushTaskAnyFilter extends AbstractGeneratedKeyEntity implements PushTaskAnyFilter {
 
     private static final long serialVersionUID = 3517381731849788407L;

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPADynRoleMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPADynRoleMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPADynRoleMembership.java
index 085bf48..dbb2fab 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPADynRoleMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPADynRoleMembership.java
@@ -43,9 +43,9 @@ public class JPADynRoleMembership extends AbstractUDynMembership implements DynR
 
     @ManyToMany
     @JoinTable(name = TABLE + "_User", joinColumns =
-            @JoinColumn(name = "dynRoleMembership_key"),
+            @JoinColumn(name = "dynRoleMembership_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "user_key"))
+            @JoinColumn(name = "user_id"))
     private List<JPAUser> users = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
index e98b8b5..53db0d9 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
@@ -43,9 +43,9 @@ public class JPAUDynGroupMembership extends AbstractUDynMembership implements UD
 
     @ManyToMany
     @JoinTable(name = TABLE + "_User", joinColumns =
-            @JoinColumn(name = "uDynGroupMembership_key"),
+            @JoinColumn(name = "uDynGroupMembership_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "user_key"))
+            @JoinColumn(name = "user_id"))
     private List<JPAUser> users = new ArrayList<>();
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
index dbdfc31..866537e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
@@ -39,11 +39,11 @@ public class JPAUMembership extends AbstractGeneratedKeyEntity implements UMembe
     public static final String TABLE = "UMembership";
 
     @ManyToOne
-    @Column(name = "user_key")
+    @Column(name = "user_id")
     private JPAUser leftEnd;
 
     @ManyToOne
-    @Column(name = "group_key")
+    @Column(name = "group_id")
     private JPAGroup rightEnd;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
index 0a0e3dc..c118c0f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
@@ -42,7 +42,7 @@ public class JPAUPlainAttrUniqueValue extends AbstractPlainAttrValue implements
     private JPAUPlainAttr attribute;
 
     @ManyToOne(optional = false)
-    @JoinColumn(name = "schema_key")
+    @JoinColumn(name = "schema_id")
     private JPAPlainSchema schema;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
index 1b3ed51..931b4e6 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
@@ -35,7 +35,7 @@ import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAAnyObject;
 
 @Entity
 @Table(name = JPAURelationship.TABLE, uniqueConstraints =
-        @UniqueConstraint(columnNames = { "type_key", "user_key", "anyObject_key" }))
+        @UniqueConstraint(columnNames = { "type_id", "user_id", "anyObject_id" }))
 public class JPAURelationship extends AbstractGeneratedKeyEntity implements URelationship {
 
     private static final long serialVersionUID = 2778494939240083204L;
@@ -46,11 +46,11 @@ public class JPAURelationship extends AbstractGeneratedKeyEntity implements URel
     private JPARelationshipType type;
 
     @ManyToOne
-    @Column(name = "user_key")
+    @Column(name = "user_id")
     private JPAUser leftEnd;
 
     @ManyToOne
-    @Column(name = "anyObject_key")
+    @Column(name = "anyObject_id")
     private JPAAnyObject rightEnd;
 
     @Override

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
index 407d2cd..a0ecf00 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
@@ -87,9 +87,9 @@ public class JPAUser extends AbstractAny<UPlainAttr> implements User {
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "user_key"),
+            @JoinColumn(name = "user_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "role_key"))
+            @JoinColumn(name = "role_id"))
     private List<JPARole> roles = new ArrayList<>();
 
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@@ -114,7 +114,7 @@ public class JPAUser extends AbstractAny<UPlainAttr> implements User {
     @ElementCollection
     @Column(name = "passwordHistoryValue")
     @CollectionTable(name = "SyncopeUser_passwordHistory", joinColumns =
-            @JoinColumn(name = "user_key", referencedColumnName = "key"))
+            @JoinColumn(name = "user_id", referencedColumnName = "id"))
     private List<String> passwordHistory = new ArrayList<>();
 
     /**
@@ -159,17 +159,17 @@ public class JPAUser extends AbstractAny<UPlainAttr> implements User {
      */
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "user_key"),
+            @JoinColumn(name = "user_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "resource_key"))
+            @JoinColumn(name = "resource_id"))
     @Valid
     private List<JPAExternalResource> resources = new ArrayList<>();
 
     @ManyToMany(fetch = FetchType.EAGER)
     @JoinTable(joinColumns =
-            @JoinColumn(name = "user_key"),
+            @JoinColumn(name = "user_id"),
             inverseJoinColumns =
-            @JoinColumn(name = "anyTypeClass_key"))
+            @JoinColumn(name = "anyTypeClass_id"))
     private List<JPAAnyTypeClass> auxClasses = new ArrayList<>();
 
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "leftEnd")

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
index 78a8098..da39ce3 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
@@ -44,7 +44,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>    
@@ -56,7 +56,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>
@@ -68,7 +68,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>
@@ -80,7 +80,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>

http://git-wip-us.apache.org/repos/asf/syncope/blob/0d745d43/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
index f27990a..8bcb833 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
@@ -44,7 +44,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>    
@@ -56,7 +56,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>
@@ -68,7 +68,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>
@@ -80,7 +80,7 @@ under the License.
         <column-name>stringValue</column-name>
         <column-name>doubleValue</column-name>
         <column-name>longValue</column-name>
-        <column-name>schema_key</column-name>
+        <column-name>schema_id</column-name>
       </unique-constraint>
     </table>
   </entity>


Mime
View raw message