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 2015/01/01 19:12:20 UTC

[25/32] syncope git commit: [SYNCOPE-620] JPA entities + basic tests

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractPlainSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractPlainSchema.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractPlainSchema.java
new file mode 100644
index 0000000..075252a
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractPlainSchema.java
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.lang.reflect.Constructor;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import org.apache.syncope.common.lib.types.AttrSchemaType;
+import org.apache.syncope.common.lib.types.CipherAlgorithm;
+import org.apache.syncope.persistence.api.attrvalue.validation.Validator;
+import org.apache.syncope.persistence.api.entity.PlainSchema;
+import org.apache.syncope.persistence.jpa.attrvalue.validation.BasicValidator;
+import org.apache.syncope.persistence.jpa.validation.entity.PlainSchemaCheck;
+import org.apache.syncope.persistence.jpa.validation.entity.SchemaNameCheck;
+
+@MappedSuperclass
+@PlainSchemaCheck
+@SchemaNameCheck
+public abstract class AbstractPlainSchema extends AbstractEntity<String> implements PlainSchema {
+
+    private static final long serialVersionUID = -8621028596062054739L;
+
+    @Id
+    private String name;
+
+    @Column(nullable = false)
+    @Enumerated(EnumType.STRING)
+    private AttrSchemaType type;
+
+    @Column(nullable = false)
+    private String mandatoryCondition;
+
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer multivalue;
+
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer uniqueConstraint;
+
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer readonly;
+
+    @Column(nullable = true)
+    private String conversionPattern;
+
+    @Column(nullable = true)
+    private String validatorClass;
+
+    @Column(nullable = true)
+    @Lob
+    private String enumerationValues;
+
+    @Column(nullable = true)
+    @Lob
+    private String enumerationKeys;
+
+    @Column(nullable = true)
+    private String secretKey;
+
+    @Column(nullable = true)
+    @Enumerated(EnumType.STRING)
+    private CipherAlgorithm cipherAlgorithm;
+
+    @Column(nullable = true)
+    private String mimeType;
+
+    @Transient
+    private Validator validator;
+
+    public AbstractPlainSchema() {
+        super();
+
+        type = AttrSchemaType.String;
+        mandatoryCondition = Boolean.FALSE.toString();
+        multivalue = getBooleanAsInteger(false);
+        uniqueConstraint = getBooleanAsInteger(false);
+        readonly = getBooleanAsInteger(false);
+    }
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String name) {
+        this.name = name;
+    }
+
+    @Override
+    public AttrSchemaType getType() {
+        return type;
+    }
+
+    @Override
+    public void setType(final AttrSchemaType type) {
+        this.type = type;
+    }
+
+    @Override
+    public String getMandatoryCondition() {
+        return mandatoryCondition;
+    }
+
+    @Override
+    public void setMandatoryCondition(final String condition) {
+        this.mandatoryCondition = condition;
+    }
+
+    @Override
+    public boolean isMultivalue() {
+        return isBooleanAsInteger(multivalue);
+    }
+
+    @Override
+    public void setMultivalue(boolean multivalue) {
+        this.multivalue = getBooleanAsInteger(multivalue);
+    }
+
+    @Override
+    public boolean isUniqueConstraint() {
+        return isBooleanAsInteger(uniqueConstraint);
+    }
+
+    @Override
+    public void setUniqueConstraint(final boolean uniquevalue) {
+        this.uniqueConstraint = getBooleanAsInteger(uniquevalue);
+    }
+
+    @Override
+    public boolean isReadonly() {
+        return isBooleanAsInteger(readonly);
+    }
+
+    @Override
+    public void setReadonly(final boolean readonly) {
+        this.readonly = getBooleanAsInteger(readonly);
+    }
+
+    @Override
+    public Validator getValidator() {
+        if (validator != null) {
+            return validator;
+        }
+
+        if (getValidatorClass() != null && getValidatorClass().length() > 0) {
+            try {
+                Constructor<?> validatorConstructor = Class.forName(getValidatorClass()).
+                        getConstructor(new Class<?>[] { PlainSchema.class });
+                validator = (Validator) validatorConstructor.newInstance(this);
+            } catch (Exception e) {
+                LOG.error("Could not instantiate validator of type {}, reverting to {}",
+                        getValidatorClass(), BasicValidator.class.getSimpleName(), e);
+            }
+        }
+
+        if (validator == null) {
+            validator = new BasicValidator(this);
+        }
+
+        return validator;
+    }
+
+    @Override
+    public String getValidatorClass() {
+        return validatorClass;
+    }
+
+    @Override
+    public void setValidatorClass(final String validatorClass) {
+        this.validatorClass = validatorClass;
+    }
+
+    @Override
+    public String getEnumerationValues() {
+        return enumerationValues;
+    }
+
+    @Override
+    public void setEnumerationValues(final String enumerationValues) {
+        this.enumerationValues = enumerationValues;
+    }
+
+    @Override
+    public String getEnumerationKeys() {
+        return enumerationKeys;
+    }
+
+    @Override
+    public void setEnumerationKeys(String enumerationKeys) {
+        this.enumerationKeys = enumerationKeys;
+    }
+
+    @Override
+    public String getConversionPattern() {
+        if (!getType().isConversionPatternNeeded()) {
+            LOG.debug("Conversion pattern is not needed: {}'s type is {}", this, getType());
+        }
+
+        return conversionPattern;
+    }
+
+    @Override
+    public void setConversionPattern(final String conversionPattern) {
+        if (!getType().isConversionPatternNeeded()) {
+            LOG.warn("Conversion pattern will be ignored: this attribute type is {}", getType());
+        }
+
+        this.conversionPattern = conversionPattern;
+    }
+
+    @Override
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    @Override
+    public void setSecretKey(final String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    @Override
+    public CipherAlgorithm getCipherAlgorithm() {
+        return cipherAlgorithm;
+    }
+
+    @Override
+    public void setCipherAlgorithm(final CipherAlgorithm cipherAlgorithm) {
+        this.cipherAlgorithm = cipherAlgorithm;
+    }
+
+    @Override
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    @Override
+    public void setMimeType(final String mimeType) {
+        this.mimeType = mimeType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractSubject.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractSubject.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractSubject.java
new file mode 100644
index 0000000..3628697
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractSubject.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.syncope.persistence.api.entity.DerAttr;
+import org.apache.syncope.persistence.api.entity.ExternalResource;
+import org.apache.syncope.persistence.api.entity.PlainAttr;
+import org.apache.syncope.persistence.api.entity.Subject;
+import org.apache.syncope.persistence.api.entity.VirAttr;
+
+public abstract class AbstractSubject<P extends PlainAttr, D extends DerAttr, V extends VirAttr>
+        extends AbstractAttributable<P, D, V> implements Subject<P, D, V> {
+
+    private static final long serialVersionUID = -6876467491398928855L;
+
+    protected abstract Set<? extends ExternalResource> internalGetResources();
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public boolean addResource(final ExternalResource resource) {
+        return ((Set<ExternalResource>) internalGetResources()).add(resource);
+    }
+
+    @Override
+    public boolean removeResource(final ExternalResource resource) {
+        return internalGetResources().remove(resource);
+    }
+
+    @Override
+    public Set<? extends ExternalResource> getResources() {
+        return internalGetResources();
+    }
+
+    @Override
+    public Set<String> getResourceNames() {
+        Set<? extends ExternalResource> ownResources = getResources();
+
+        Set<String> result = new HashSet<>(ownResources.size());
+        for (ExternalResource resource : ownResources) {
+            result.add(resource.getKey());
+        }
+
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirAttr.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirAttr.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirAttr.java
new file mode 100644
index 0000000..3805489
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirAttr.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import org.apache.syncope.persistence.api.entity.VirAttr;
+
+@MappedSuperclass
+public abstract class AbstractVirAttr extends AbstractEntity<Long> implements VirAttr {
+
+    private static final long serialVersionUID = 5023204776925954907L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    protected Long id;
+
+    @Transient
+    protected List<String> values = new ArrayList<>();
+
+    @Override
+    public Long getKey() {
+        return id;
+    }
+
+    @Override
+    public List<String> getValues() {
+        return values;
+    }
+
+    @Override
+    public boolean addValue(final String value) {
+        return !values.contains(value) && values.add(value);
+    }
+
+    @Override
+    public boolean removeValue(final String value) {
+        return values.remove(value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirSchema.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirSchema.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirSchema.java
new file mode 100644
index 0000000..311350e
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AbstractVirSchema.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import javax.persistence.Basic;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import org.apache.syncope.common.lib.types.AttrSchemaType;
+import org.apache.syncope.persistence.api.entity.VirSchema;
+import org.apache.syncope.persistence.jpa.validation.entity.SchemaNameCheck;
+
+@MappedSuperclass
+@SchemaNameCheck
+public abstract class AbstractVirSchema extends AbstractEntity<String> implements VirSchema {
+
+    private static final long serialVersionUID = 3274006935328590141L;
+
+    @Id
+    private String name;
+
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer readonly;
+
+    public AbstractVirSchema() {
+        super();
+
+        readonly = getBooleanAsInteger(false);
+    }
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String key) {
+        this.name = key;
+    }
+
+    @Override
+    public AttrSchemaType getType() {
+        return AttrSchemaType.String;
+    }
+
+    @Override
+    public String getMandatoryCondition() {
+        return Boolean.FALSE.toString().toLowerCase();
+    }
+
+    @Override
+    public boolean isMultivalue() {
+        return Boolean.TRUE;
+    }
+
+    @Override
+    public boolean isUniqueConstraint() {
+        return Boolean.FALSE;
+    }
+
+    @Override
+    public boolean isReadonly() {
+        return isBooleanAsInteger(readonly);
+    }
+
+    @Override
+    public void setReadonly(final boolean readonly) {
+        this.readonly = getBooleanAsInteger(readonly);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AnnotatedEntityListener.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AnnotatedEntityListener.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AnnotatedEntityListener.java
new file mode 100644
index 0000000..e6ce64f
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/AnnotatedEntityListener.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.Date;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import org.apache.syncope.persistence.api.entity.AnnotatedEntity;
+import org.apache.syncope.server.security.AuthContextUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AnnotatedEntityListener {
+
+    /**
+     * Logger.
+     */
+    private static final Logger LOG = LoggerFactory.getLogger(AnnotatedEntityListener.class);
+
+    @PrePersist
+    @PreUpdate
+    public void setSysInfo(final AnnotatedEntity entity) {
+        final String username = AuthContextUtil.getAuthenticatedUsername();
+        LOG.debug("Set system properties for '{}'", entity);
+
+        final Date now = new Date();
+
+        if (entity.getCreationDate() == null) {
+            LOG.debug("Set creation date '{}' and creator '{}' for '{}'", now, username, entity);
+            entity.setCreationDate(now);
+            entity.setCreator(username);
+        }
+
+        LOG.debug("Set last change date '{}' and modifier '{}' for '{}'", now, username, entity);
+        entity.setLastModifier(username);
+        entity.setLastChangeDate(now);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAccountPolicy.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAccountPolicy.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAccountPolicy.java
new file mode 100644
index 0000000..229dd43
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAccountPolicy.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.validation.Valid;
+import org.apache.syncope.common.lib.types.PolicyType;
+import org.apache.syncope.persistence.api.entity.AccountPolicy;
+import org.apache.syncope.persistence.api.entity.ExternalResource;
+
+@Entity
+@DiscriminatorValue("AccountPolicy")
+public class JPAAccountPolicy extends JPAPolicy implements AccountPolicy {
+
+    private static final long serialVersionUID = -2767606675667839060L;
+
+    /**
+     * Resources for alternative user authentication: if empty, only internal storage will be used.
+     */
+    @ManyToMany(fetch = FetchType.EAGER)
+    @JoinTable(joinColumns =
+            @JoinColumn(name = "account_policy_id"),
+            inverseJoinColumns =
+            @JoinColumn(name = "resource_name"))
+    @Valid
+    private Set<JPAExternalResource> resources;
+
+    public JPAAccountPolicy() {
+        this(false);
+        this.resources = new HashSet<>();
+    }
+
+    public JPAAccountPolicy(final boolean global) {
+        super();
+
+        this.type = global
+                ? PolicyType.GLOBAL_ACCOUNT
+                : PolicyType.ACCOUNT;
+    }
+
+    @Override
+    public boolean addResource(final ExternalResource resource) {
+        checkType(resource, JPAExternalResource.class);
+        return resources.add((JPAExternalResource) resource);
+    }
+
+    @Override
+    public boolean removeResource(final ExternalResource resource) {
+        checkType(resource, JPAExternalResource.class);
+        return resources.remove((JPAExternalResource) resource);
+    }
+
+    @Override
+    public Set<? extends ExternalResource> getResources() {
+        return resources;
+    }
+
+    @Override
+    public Set<String> getResourceNames() {
+        Set<String> result = new HashSet<>(resources.size());
+        for (ExternalResource resource : resources) {
+            result.add(resource.getKey());
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
new file mode 100644
index 0000000..2705285
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAAttributableUtil.java
@@ -0,0 +1,882 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.MappingPurpose;
+import org.apache.syncope.persistence.api.entity.AttrTemplate;
+import org.apache.syncope.persistence.api.entity.Attributable;
+import org.apache.syncope.persistence.api.entity.AttributableUtil;
+import org.apache.syncope.persistence.api.entity.DerAttr;
+import org.apache.syncope.persistence.api.entity.DerSchema;
+import org.apache.syncope.persistence.api.entity.ExternalResource;
+import org.apache.syncope.persistence.api.entity.MappingItem;
+import org.apache.syncope.persistence.api.entity.PlainAttr;
+import org.apache.syncope.persistence.api.entity.PlainAttrValue;
+import org.apache.syncope.persistence.api.entity.PlainSchema;
+import org.apache.syncope.persistence.api.entity.VirAttr;
+import org.apache.syncope.persistence.api.entity.VirSchema;
+import org.apache.syncope.persistence.api.entity.conf.Conf;
+import org.apache.syncope.persistence.api.entity.membership.Membership;
+import org.apache.syncope.persistence.api.entity.role.Role;
+import org.apache.syncope.persistence.api.entity.user.User;
+import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttr;
+import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttrUniqueValue;
+import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainAttrValue;
+import org.apache.syncope.persistence.jpa.entity.conf.JPACPlainSchema;
+import org.apache.syncope.persistence.jpa.entity.conf.JPAConf;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMDerAttr;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMDerAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMDerSchema;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMPlainAttr;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMPlainAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMPlainAttrUniqueValue;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMPlainAttrValue;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMPlainSchema;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMVirAttr;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMVirAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMVirSchema;
+import org.apache.syncope.persistence.jpa.entity.membership.JPAMembership;
+import org.apache.syncope.persistence.jpa.entity.role.JPARDerAttr;
+import org.apache.syncope.persistence.jpa.entity.role.JPARDerAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.role.JPARDerSchema;
+import org.apache.syncope.persistence.jpa.entity.role.JPARMappingItem;
+import org.apache.syncope.persistence.jpa.entity.role.JPARPlainAttr;
+import org.apache.syncope.persistence.jpa.entity.role.JPARPlainAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.role.JPARPlainAttrUniqueValue;
+import org.apache.syncope.persistence.jpa.entity.role.JPARPlainAttrValue;
+import org.apache.syncope.persistence.jpa.entity.role.JPARPlainSchema;
+import org.apache.syncope.persistence.jpa.entity.role.JPARVirAttr;
+import org.apache.syncope.persistence.jpa.entity.role.JPARVirAttrTemplate;
+import org.apache.syncope.persistence.jpa.entity.role.JPARVirSchema;
+import org.apache.syncope.persistence.jpa.entity.role.JPARole;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUDerAttr;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUDerSchema;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUMappingItem;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUPlainAttr;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUPlainAttrUniqueValue;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUPlainAttrValue;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUPlainSchema;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUVirAttr;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUVirSchema;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUser;
+import org.apache.syncope.server.spring.BeanUtils;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class JPAAttributableUtil implements AttributableUtil {
+
+    /**
+     * Logger.
+     */
+    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(AttributableUtil.class);
+
+    public static AttributableUtil getInstance(final AttributableType type) {
+        return new JPAAttributableUtil(type);
+    }
+
+    public static AttributableUtil valueOf(final String name) {
+        return new JPAAttributableUtil(AttributableType.valueOf(name));
+    }
+
+    public static AttributableUtil getInstance(final ObjectClass objectClass) {
+        AttributableType type = null;
+        if (ObjectClass.ACCOUNT.equals(objectClass)) {
+            type = AttributableType.USER;
+        }
+        if (ObjectClass.GROUP.equals(objectClass)) {
+            type = AttributableType.ROLE;
+        }
+
+        if (type == null) {
+            throw new IllegalArgumentException("ObjectClass not supported: " + objectClass);
+        }
+
+        return new JPAAttributableUtil(type);
+    }
+
+    public static AttributableUtil getInstance(final Attributable attributable) {
+        AttributableType type = null;
+        if (attributable instanceof User) {
+            type = AttributableType.USER;
+        }
+        if (attributable instanceof Role) {
+            type = AttributableType.ROLE;
+        }
+        if (attributable instanceof Membership) {
+            type = AttributableType.MEMBERSHIP;
+        }
+        if (attributable instanceof Conf) {
+            type = AttributableType.CONFIGURATION;
+        }
+
+        if (type == null) {
+            throw new IllegalArgumentException("Attributable type not supported: " + attributable.getClass().getName());
+        }
+
+        return new JPAAttributableUtil(type);
+    }
+
+    private final AttributableType type;
+
+    private JPAAttributableUtil(final AttributableType type) {
+        this.type = type;
+    }
+
+    @Override
+    public AttributableType getType() {
+        return type;
+    }
+
+    @Override
+    public <T extends Attributable<?, ?, ?>> Class<T> attributableClass() {
+        Class result;
+
+        switch (type) {
+            case ROLE:
+                result = JPARole.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMembership.class;
+                break;
+
+            case CONFIGURATION:
+                result = JPAConf.class;
+                break;
+
+            case USER:
+            default:
+                result = JPAUser.class;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainSchema> Class<T> plainSchemaClass() {
+        Class result;
+
+        switch (type) {
+            case ROLE:
+                result = JPARPlainSchema.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMPlainSchema.class;
+                break;
+
+            case CONFIGURATION:
+                result = JPACPlainSchema.class;
+                break;
+
+            case USER:
+            default:
+                result = JPAUPlainSchema.class;
+                break;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainSchema> T newPlainSchema() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUPlainSchema();
+                break;
+
+            case ROLE:
+                result = (T) new JPARPlainSchema();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMPlainSchema();
+                break;
+
+            case CONFIGURATION:
+                result = (T) new JPACPlainSchema();
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttr> Class<T> plainAttrClass() {
+        Class result = null;
+
+        switch (type) {
+            case ROLE:
+                result = JPARPlainAttr.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMPlainAttr.class;
+                break;
+
+            case CONFIGURATION:
+                result = JPACPlainAttr.class;
+                break;
+
+            case USER:
+            default:
+                result = JPAUPlainAttr.class;
+                break;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttr> T newPlainAttr() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUPlainAttr();
+                break;
+
+            case ROLE:
+                result = (T) new JPARPlainAttr();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMPlainAttr();
+                break;
+
+            case CONFIGURATION:
+                result = (T) new JPACPlainAttr();
+
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttrValue> Class<T> plainAttrValueClass() {
+        Class result;
+
+        switch (type) {
+            case ROLE:
+                result = JPARPlainAttrValue.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMPlainAttrValue.class;
+                break;
+
+            case CONFIGURATION:
+                result = JPACPlainAttrValue.class;
+                break;
+
+            case USER:
+            default:
+                result = JPAUPlainAttrValue.class;
+                break;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttrValue> T newPlainAttrValue() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUPlainAttrValue();
+                break;
+
+            case ROLE:
+                result = (T) new JPARPlainAttrValue();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMPlainAttrValue();
+                break;
+
+            case CONFIGURATION:
+                result = (T) new JPACPlainAttrValue();
+                break;
+
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttrValue> Class<T> plainAttrUniqueValueClass() {
+        Class result;
+
+        switch (type) {
+            case ROLE:
+                result = JPARPlainAttrUniqueValue.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMPlainAttrUniqueValue.class;
+                break;
+
+            case CONFIGURATION:
+                result = JPACPlainAttrUniqueValue.class;
+                break;
+
+            case USER:
+            default:
+                result = JPAUPlainAttrUniqueValue.class;
+                break;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends PlainAttrValue> T newPlainAttrUniqueValue() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUPlainAttrUniqueValue();
+                break;
+
+            case ROLE:
+                result = (T) new JPARPlainAttrUniqueValue();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMPlainAttrUniqueValue();
+                break;
+
+            case CONFIGURATION:
+                result = (T) new JPACPlainAttrUniqueValue();
+                break;
+
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends AttrTemplate<PlainSchema>> Class<T> plainAttrTemplateClass() {
+        Class result;
+
+        switch (type) {
+            case ROLE:
+                result = JPARPlainAttrTemplate.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMPlainAttrTemplate.class;
+                break;
+
+            case USER:
+            case CONFIGURATION:
+            default:
+                result = null;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends DerSchema> Class<T> derSchemaClass() {
+        Class result;
+
+        switch (type) {
+            case USER:
+                result = JPAUDerSchema.class;
+                break;
+
+            case ROLE:
+                result = JPARDerSchema.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMDerSchema.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+                result = null;
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends DerSchema> T newDerSchema() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUDerSchema();
+                break;
+
+            case ROLE:
+                result = (T) new JPARDerSchema();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMDerSchema();
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends DerAttr> Class<T> derAttrClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                result = JPAUDerAttr.class;
+                break;
+
+            case ROLE:
+                result = JPARDerAttr.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMDerAttr.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends DerAttr> T newDerAttr() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUDerAttr();
+                break;
+
+            case ROLE:
+                result = (T) new JPARDerAttr();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMDerAttr();
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends AttrTemplate<DerSchema>> Class<T> derAttrTemplateClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                break;
+
+            case ROLE:
+                result = JPARDerAttrTemplate.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMDerAttrTemplate.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends VirSchema> Class<T> virSchemaClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                result = JPAUVirSchema.class;
+                break;
+
+            case ROLE:
+                result = JPARVirSchema.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMVirSchema.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends VirSchema> T newVirSchema() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUVirSchema();
+                break;
+
+            case ROLE:
+                result = (T) new JPARVirSchema();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMVirSchema();
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends VirAttr> Class<T> virAttrClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                result = JPAUVirAttr.class;
+                break;
+
+            case ROLE:
+                result = JPARVirAttr.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMVirAttr.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends VirAttr> T newVirAttr() {
+        T result = null;
+
+        switch (type) {
+            case USER:
+                result = (T) new JPAUVirAttr();
+                break;
+
+            case ROLE:
+                result = (T) new JPARVirAttr();
+                break;
+
+            case MEMBERSHIP:
+                result = (T) new JPAMVirAttr();
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends AttrTemplate<VirSchema>> Class<T> virAttrTemplateClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                break;
+
+            case ROLE:
+                result = JPARVirAttrTemplate.class;
+                break;
+
+            case MEMBERSHIP:
+                result = JPAMVirAttrTemplate.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends MappingItem> T getAccountIdItem(final ExternalResource resource) {
+        T result = null;
+
+        if (resource != null) {
+            switch (type) {
+                case ROLE:
+                    if (resource.getRmapping() != null) {
+                        result = (T) resource.getRmapping().getAccountIdItem();
+                    }
+                    break;
+
+                case MEMBERSHIP:
+                case USER:
+                    if (resource.getUmapping() != null) {
+                        result = (T) resource.getUmapping().getAccountIdItem();
+                    }
+                    break;
+
+                default:
+            }
+        }
+
+        return result;
+    }
+
+    @Override
+    public String getAccountLink(final ExternalResource resource) {
+        String result = null;
+
+        if (resource != null) {
+            switch (type) {
+                case USER:
+                    if (resource.getUmapping() != null) {
+                        result = resource.getUmapping().getAccountLink();
+                    }
+                    break;
+
+                case ROLE:
+                    if (resource.getRmapping() != null) {
+                        result = resource.getRmapping().getAccountLink();
+                    }
+                    break;
+
+                case MEMBERSHIP:
+                case CONFIGURATION:
+                default:
+            }
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends MappingItem> List<T> getMappingItems(
+            final ExternalResource resource, final MappingPurpose purpose) {
+
+        List<T> items = Collections.<T>emptyList();
+
+        if (resource != null) {
+            switch (type) {
+                case ROLE:
+                    if (resource.getRmapping() != null) {
+                        items = (List<T>) resource.getRmapping().getItems();
+                    }
+                    break;
+
+                case MEMBERSHIP:
+                case USER:
+                    if (resource.getUmapping() != null) {
+                        items = (List<T>) resource.getUmapping().getItems();
+                    }
+                    break;
+
+                default:
+            }
+        }
+
+        final List<T> result = new ArrayList<T>();
+
+        switch (purpose) {
+            case SYNCHRONIZATION:
+                for (T item : items) {
+                    if (MappingPurpose.PROPAGATION != item.getPurpose()
+                            && MappingPurpose.NONE != item.getPurpose()) {
+
+                        result.add(item);
+                    }
+                }
+                break;
+
+            case PROPAGATION:
+                for (T item : items) {
+                    if (MappingPurpose.SYNCHRONIZATION != item.getPurpose()
+                            && MappingPurpose.NONE != item.getPurpose()) {
+
+                        result.add(item);
+                    }
+                }
+                break;
+
+            case BOTH:
+                for (T item : items) {
+                    if (MappingPurpose.NONE != item.getPurpose()) {
+                        result.add(item);
+                    }
+                }
+                break;
+
+            case NONE:
+                for (T item : items) {
+                    if (MappingPurpose.NONE == item.getPurpose()) {
+                        result.add(item);
+                    }
+                }
+                break;
+            default:
+                LOG.error("You requested not existing purpose {}", purpose);
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends MappingItem> List<T> getUidToMappingItems(
+            final ExternalResource resource, final MappingPurpose purpose) {
+
+        List<T> items = getMappingItems(resource, purpose);
+
+        MappingItem uidItem = type == AttributableType.USER ? new JPAUMappingItem() : new JPARMappingItem();
+        BeanUtils.copyProperties(getAccountIdItem(resource), uidItem);
+        uidItem.setExtAttrName(Uid.NAME);
+        uidItem.setAccountid(false);
+        items.add((T) uidItem);
+
+        return items;
+    }
+
+    @Override
+    public IntMappingType intMappingType() {
+        IntMappingType result = null;
+
+        switch (type) {
+            case ROLE:
+                result = IntMappingType.RoleSchema;
+                break;
+
+            case MEMBERSHIP:
+                result = IntMappingType.MembershipSchema;
+                break;
+
+            case USER:
+                result = IntMappingType.UserSchema;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public IntMappingType derIntMappingType() {
+        IntMappingType result = null;
+
+        switch (type) {
+            case ROLE:
+                result = IntMappingType.RoleSchema;
+                break;
+
+            case MEMBERSHIP:
+                result = IntMappingType.MembershipSchema;
+                break;
+
+            case USER:
+                result = IntMappingType.UserSchema;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public IntMappingType virIntMappingType() {
+        IntMappingType result = null;
+
+        switch (type) {
+            case ROLE:
+                result = IntMappingType.RoleVirtualSchema;
+                break;
+
+            case MEMBERSHIP:
+                result = IntMappingType.MembershipVirtualSchema;
+                break;
+
+            case USER:
+                result = IntMappingType.UserVirtualSchema;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+    @Override
+    public <T extends MappingItem> Class<T> mappingItemClass() {
+        Class result = null;
+
+        switch (type) {
+            case USER:
+                result = JPAUMappingItem.class;
+                break;
+
+            case ROLE:
+                result = JPARMappingItem.class;
+                break;
+
+            case MEMBERSHIP:
+                result = AbstractMappingItem.class;
+                break;
+
+            case CONFIGURATION:
+            default:
+        }
+
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnInstance.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnInstance.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnInstance.java
new file mode 100644
index 0000000..271f899
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnInstance.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.types.ConnConfProperty;
+import org.apache.syncope.common.lib.types.ConnectorCapability;
+import org.apache.syncope.persistence.api.entity.ConnInstance;
+import org.apache.syncope.persistence.api.entity.ConnPoolConf;
+import org.apache.syncope.persistence.api.entity.ExternalResource;
+import org.apache.syncope.persistence.jpa.validation.entity.ConnInstanceCheck;
+import org.apache.syncope.server.utils.serialization.POJOHelper;
+
+@Entity
+@Table(name = JPAConnInstance.TABLE)
+@ConnInstanceCheck
+public class JPAConnInstance extends AbstractEntity<Long> implements ConnInstance {
+
+    private static final long serialVersionUID = -2294708794497208872L;
+
+    public static final String TABLE = "ConnInstance";
+
+    private static final int DEFAULT_TIMEOUT = 10;
+
+    @Id
+    private Long id;
+
+    /**
+     * URI identifying the local / remote ConnId location where the related connector bundle is found.
+     */
+    @Column(nullable = false)
+    private String location;
+
+    /**
+     * Connector bundle class name.
+     * Within a given location, the triple
+     * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique.
+     */
+    @Column(nullable = false)
+    private String connectorName;
+
+    /**
+     * Qualified name for the connector bundle.
+     * Within a given location, the triple
+     * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique.
+     */
+    @Column(nullable = false)
+    private String bundleName;
+
+    /**
+     * Version of the bundle.
+     * Within a given location, the triple
+     * (ConnectorBundle-Name, ConnectorBundle-Version, ConnectorBundle-Version) must be unique.
+     */
+    @Column(nullable = false)
+    private String version;
+
+    /**
+     * The set of capabilities supported by this connector instance.
+     */
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Enumerated(EnumType.STRING)
+    @Column(name = "capabilities")
+    @CollectionTable(name = "ConnInstance_capabilities",
+            joinColumns =
+            @JoinColumn(name = "ConnInstance_id", referencedColumnName = "id"))
+    private Set<ConnectorCapability> capabilities;
+
+    /**
+     * The main configuration for the connector instance. This is directly implemented by the Configuration bean class
+     * which contains annotated ConfigurationProperties.
+     *
+     * @see org.identityconnectors.framework.api.ConfigurationProperty
+     */
+    @Lob
+    private String jsonConf;
+
+    @Column(unique = true)
+    private String displayName;
+
+    /**
+     * External resources associated to the connector.
+     */
+    @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "connector")
+    private List<JPAExternalResource> resources;
+
+    /**
+     * Connector request timeout. It is not applied in case of sync, full reconciliation and search.
+     * DEFAULT_TIMEOUT is the default value to be used in case of unspecified timeout.
+     */
+    private Integer connRequestTimeout = DEFAULT_TIMEOUT;
+
+    private JPAConnPoolConf poolConf;
+
+    public JPAConnInstance() {
+        super();
+
+        capabilities = new HashSet<>();
+        resources = new ArrayList<>();
+    }
+
+    @Override
+    public Long getKey() {
+        return id;
+    }
+
+    @Override
+    public String getLocation() {
+        return location;
+    }
+
+    @Override
+    public void setLocation(final String location) {
+        this.location = location;
+    }
+
+    @Override
+    public String getConnectorName() {
+        return connectorName;
+    }
+
+    @Override
+    public void setConnectorName(final String connectorName) {
+        this.connectorName = connectorName;
+    }
+
+    @Override
+    public String getBundleName() {
+        return bundleName;
+    }
+
+    @Override
+    public void setBundleName(final String bundleName) {
+        this.bundleName = bundleName;
+    }
+
+    @Override
+    public String getVersion() {
+        return version;
+    }
+
+    @Override
+    public void setVersion(final String version) {
+        this.version = version;
+    }
+
+    @Override
+    public Set<ConnConfProperty> getConfiguration() {
+        Set<ConnConfProperty> configuration = Collections.<ConnConfProperty>emptySet();
+        if (!StringUtils.isBlank(jsonConf)) {
+            ConnConfProperty[] deserialized = POJOHelper.deserialize(jsonConf, ConnConfProperty[].class);
+            if (ArrayUtils.isNotEmpty(deserialized)) {
+                configuration = new HashSet<ConnConfProperty>(Arrays.asList(deserialized));
+            }
+        }
+
+        return configuration;
+    }
+
+    @Override
+    public void setConfiguration(final Set<ConnConfProperty> configuration) {
+        jsonConf = POJOHelper.serialize(new HashSet<ConnConfProperty>(configuration));
+    }
+
+    @Override
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    @Override
+    public void setDisplayName(final String displayName) {
+        this.displayName = displayName;
+    }
+
+    @Override
+    public List<? extends ExternalResource> getResources() {
+        return this.resources;
+    }
+
+    @Override
+    public boolean addResource(final ExternalResource resource) {
+        checkType(resource, JPAExternalResource.class);
+        return this.resources.contains((JPAExternalResource) resource)
+                || this.resources.add((JPAExternalResource) resource);
+    }
+
+    @Override
+    public boolean removeResource(final ExternalResource resource) {
+        checkType(resource, JPAExternalResource.class);
+        return this.resources.remove((JPAExternalResource) resource);
+    }
+
+    @Override
+    public boolean addCapability(final ConnectorCapability capabitily) {
+        return capabilities.add(capabitily);
+    }
+
+    @Override
+    public boolean removeCapability(final ConnectorCapability capabitily) {
+        return capabilities.remove(capabitily);
+    }
+
+    @Override
+    public Set<ConnectorCapability> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public Integer getConnRequestTimeout() {
+        // DEFAULT_TIMEOUT will be returned in case of null timeout:
+        // * instances created by the content loader 
+        // * or with a timeout nullified explicitely
+        return connRequestTimeout == null ? DEFAULT_TIMEOUT : connRequestTimeout;
+    }
+
+    @Override
+    public void setConnRequestTimeout(final Integer timeout) {
+        this.connRequestTimeout = timeout;
+    }
+
+    @Override
+    public ConnPoolConf getPoolConf() {
+        return poolConf;
+    }
+
+    @Override
+    public void setPoolConf(final ConnPoolConf poolConf) {
+        checkType(poolConf, JPAConnPoolConf.class);
+        this.poolConf = (JPAConnPoolConf) poolConf;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnPoolConf.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnPoolConf.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnPoolConf.java
new file mode 100644
index 0000000..a7ed759
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAConnPoolConf.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.io.Serializable;
+import javax.persistence.Embeddable;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.syncope.persistence.api.entity.ConnPoolConf;
+
+@Embeddable
+public class JPAConnPoolConf implements ConnPoolConf, Serializable {
+
+    private static final long serialVersionUID = -34259572059178970L;
+
+    private Integer maxObjects;
+
+    private Integer minIdle;
+
+    private Integer maxIdle;
+
+    private Long maxWait;
+
+    private Long minEvictableIdleTimeMillis;
+
+    @Override
+    public Integer getMaxObjects() {
+        return maxObjects;
+    }
+
+    @Override
+    public void setMaxObjects(final Integer maxObjects) {
+        this.maxObjects = maxObjects;
+    }
+
+    @Override
+    public Integer getMinIdle() {
+        return minIdle;
+    }
+
+    @Override
+    public void setMinIdle(final Integer minIdle) {
+        this.minIdle = minIdle;
+    }
+
+    @Override
+    public Integer getMaxIdle() {
+        return maxIdle;
+    }
+
+    @Override
+    public void setMaxIdle(final Integer maxIdle) {
+        this.maxIdle = maxIdle;
+    }
+
+    @Override
+    public Long getMaxWait() {
+        return maxWait;
+    }
+
+    @Override
+    public void setMaxWait(final Long maxWait) {
+        this.maxWait = maxWait;
+    }
+
+    @Override
+    public Long getMinEvictableIdleTimeMillis() {
+        return minEvictableIdleTimeMillis;
+    }
+
+    @Override
+    public void setMinEvictableIdleTimeMillis(final Long minEvictableIdleTimeMillis) {
+        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return EqualsBuilder.reflectionEquals(this, obj);
+    }
+
+    @Override
+    public int hashCode() {
+        return HashCodeBuilder.reflectionHashCode(this);
+    }
+
+    @Override
+    public String toString() {
+        return ToStringBuilder.reflectionToString(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntitlement.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntitlement.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntitlement.java
new file mode 100644
index 0000000..f96f4bc
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAEntitlement.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.syncope.persistence.api.entity.Entitlement;
+
+@Entity
+@Table(name = JPAEntitlement.TABLE)
+@Cacheable
+public class JPAEntitlement extends AbstractEntity<String> implements Entitlement {
+
+    private static final long serialVersionUID = 8044745999246422483L;
+
+    public static final String TABLE = "Entitlement";
+
+    @Id
+    private String name;
+
+    @Column(nullable = true)
+    private String description;
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String key) {
+        this.name = key;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public void setDescription(final String description) {
+        this.description = description;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAExternalResource.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAExternalResource.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAExternalResource.java
new file mode 100644
index 0000000..2b055bd
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPAExternalResource.java
@@ -0,0 +1,426 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.types.ConnConfProperty;
+import org.apache.syncope.common.lib.types.PropagationMode;
+import org.apache.syncope.common.lib.types.TraceLevel;
+import org.apache.syncope.persistence.api.entity.AccountPolicy;
+import org.apache.syncope.persistence.api.entity.ConnInstance;
+import org.apache.syncope.persistence.api.entity.ExternalResource;
+import org.apache.syncope.persistence.api.entity.PasswordPolicy;
+import org.apache.syncope.persistence.api.entity.SyncPolicy;
+import org.apache.syncope.persistence.api.entity.role.RMapping;
+import org.apache.syncope.persistence.api.entity.user.UMapping;
+import org.apache.syncope.persistence.jpa.validation.entity.ExternalResourceCheck;
+import org.apache.syncope.persistence.jpa.entity.role.JPARMapping;
+import org.apache.syncope.persistence.jpa.entity.user.JPAUMapping;
+import org.apache.syncope.server.utils.serialization.POJOHelper;
+import org.identityconnectors.framework.common.objects.SyncToken;
+
+/**
+ * Resource for propagation and synchronization.
+ */
+@Entity
+@Table(name = JPAExternalResource.TABLE)
+@ExternalResourceCheck
+public class JPAExternalResource extends AbstractAnnotatedEntity<String> implements ExternalResource {
+
+    private static final long serialVersionUID = -6937712883512073278L;
+
+    public static final String TABLE = "ExternalResource";
+
+    /**
+     * The resource identifier is the name.
+     */
+    @Id
+    private String name;
+
+    /**
+     * Should this resource enforce the mandatory constraints?
+     */
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer enforceMandatoryCondition;
+
+    /**
+     * The resource type is identified by the associated connector.
+     */
+    @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.MERGE })
+    @NotNull
+    private JPAConnInstance connector;
+
+    /**
+     * Mapping for user objects.
+     */
+    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "resource")
+    private JPAUMapping umapping;
+
+    /**
+     * Mapping for role objects.
+     */
+    @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "resource")
+    private JPARMapping rmapping;
+
+    /**
+     * Is this resource primary, for propagations?
+     */
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer propagationPrimary;
+
+    /**
+     * Priority index for propagation ordering.
+     */
+    @Column(nullable = false)
+    private Integer propagationPriority;
+
+    /**
+     * Generate random password for propagation, if not provided?
+     */
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer randomPwdIfNotProvided;
+
+    @Enumerated(EnumType.STRING)
+    @Column(nullable = false)
+    private PropagationMode propagationMode;
+
+    @Enumerated(EnumType.STRING)
+    @Column(nullable = false)
+    private TraceLevel createTraceLevel;
+
+    @Enumerated(EnumType.STRING)
+    @Column(nullable = false)
+    private TraceLevel updateTraceLevel;
+
+    @Enumerated(EnumType.STRING)
+    @Column(nullable = false)
+    private TraceLevel deleteTraceLevel;
+
+    @Enumerated(EnumType.STRING)
+    @Column(nullable = false)
+    private TraceLevel syncTraceLevel;
+
+    @ManyToOne(fetch = FetchType.EAGER, optional = true)
+    private JPAPasswordPolicy passwordPolicy;
+
+    @ManyToOne(fetch = FetchType.EAGER, optional = true)
+    private JPAAccountPolicy accountPolicy;
+
+    @ManyToOne(fetch = FetchType.EAGER, optional = true)
+    private JPASyncPolicy syncPolicy;
+
+    /**
+     * Configuration properties that are overridden from the connector instance.
+     */
+    @Lob
+    private String jsonConf;
+
+    /**
+     * SyncToken for calling ConnId's sync() on users.
+     */
+    @Lob
+    private String userializedSyncToken;
+
+    /**
+     * SyncToken for calling ConnId's sync() on roles.
+     */
+    @Lob
+    private String rserializedSyncToken;
+
+    /**
+     * (Optional) classes for PropagationAction.
+     */
+    @ElementCollection(fetch = FetchType.EAGER)
+    @Column(name = "action")
+    @CollectionTable(name = "ExternalResource_PropActions",
+            joinColumns =
+            @JoinColumn(name = "ExternalResource_name", referencedColumnName = "name"))
+    private List<String> propagationActionsClassNames = new ArrayList<>();
+
+    /**
+     * Default constructor.
+     */
+    public JPAExternalResource() {
+        super();
+
+        enforceMandatoryCondition = getBooleanAsInteger(false);
+        propagationPrimary = 0;
+        propagationPriority = 0;
+        randomPwdIfNotProvided = 0;
+        propagationMode = PropagationMode.TWO_PHASES;
+
+        createTraceLevel = TraceLevel.FAILURES;
+        updateTraceLevel = TraceLevel.FAILURES;
+        deleteTraceLevel = TraceLevel.FAILURES;
+        syncTraceLevel = TraceLevel.FAILURES;
+    }
+
+    @Override
+    public boolean isEnforceMandatoryCondition() {
+        return isBooleanAsInteger(enforceMandatoryCondition);
+    }
+
+    @Override
+    public void setEnforceMandatoryCondition(boolean enforceMandatoryCondition) {
+        this.enforceMandatoryCondition = getBooleanAsInteger(enforceMandatoryCondition);
+    }
+
+    @Override
+    public ConnInstance getConnector() {
+        return connector;
+    }
+
+    @Override
+    public void setConnector(final ConnInstance connector) {
+        checkType(connector, JPAConnInstance.class);
+        this.connector = (JPAConnInstance) connector;
+    }
+
+    @Override
+    public UMapping getUmapping() {
+        return umapping;
+    }
+
+    @Override
+    public void setUmapping(final UMapping umapping) {
+        checkType(umapping, JPAUMapping.class);
+        this.umapping = (JPAUMapping) umapping;
+    }
+
+    @Override
+    public RMapping getRmapping() {
+        return rmapping;
+    }
+
+    @Override
+    public void setRmapping(final RMapping rmapping) {
+        checkType(rmapping, JPARMapping.class);
+        this.rmapping = (JPARMapping) rmapping;
+    }
+
+    @Override
+    public boolean isPropagationPrimary() {
+        return isBooleanAsInteger(propagationPrimary);
+    }
+
+    @Override
+    public void setPropagationPrimary(boolean propagationPrimary) {
+        this.propagationPrimary = getBooleanAsInteger(propagationPrimary);
+    }
+
+    @Override
+    public Integer getPropagationPriority() {
+        return propagationPriority;
+    }
+
+    @Override
+    public void setPropagationPriority(Integer propagationPriority) {
+        if (propagationPriority != null) {
+            this.propagationPriority = propagationPriority;
+        }
+    }
+
+    @Override
+    public boolean isRandomPwdIfNotProvided() {
+        return isBooleanAsInteger(randomPwdIfNotProvided);
+    }
+
+    @Override
+    public void setRandomPwdIfNotProvided(boolean randomPwdIfNotProvided) {
+        this.randomPwdIfNotProvided = getBooleanAsInteger(randomPwdIfNotProvided);
+    }
+
+    @Override
+    public PropagationMode getPropagationMode() {
+        return propagationMode;
+    }
+
+    @Override
+    public void setPropagationMode(PropagationMode propagationMode) {
+        this.propagationMode = propagationMode;
+    }
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String name) {
+        this.name = name;
+    }
+
+    @Override
+    public TraceLevel getCreateTraceLevel() {
+        return createTraceLevel;
+    }
+
+    @Override
+    public void setCreateTraceLevel(final TraceLevel createTraceLevel) {
+        this.createTraceLevel = createTraceLevel;
+    }
+
+    @Override
+
+    public TraceLevel getDeleteTraceLevel() {
+        return deleteTraceLevel;
+    }
+
+    @Override
+    public void setDeleteTraceLevel(final TraceLevel deleteTraceLevel) {
+        this.deleteTraceLevel = deleteTraceLevel;
+    }
+
+    @Override
+    public TraceLevel getUpdateTraceLevel() {
+        return updateTraceLevel;
+    }
+
+    @Override
+    public void setUpdateTraceLevel(final TraceLevel updateTraceLevel) {
+        this.updateTraceLevel = updateTraceLevel;
+    }
+
+    @Override
+    public TraceLevel getSyncTraceLevel() {
+        return syncTraceLevel;
+    }
+
+    @Override
+    public void setSyncTraceLevel(final TraceLevel syncTraceLevel) {
+        this.syncTraceLevel = syncTraceLevel;
+    }
+
+    @Override
+    public AccountPolicy getAccountPolicy() {
+        return accountPolicy;
+    }
+
+    @Override
+    public void setAccountPolicy(final AccountPolicy accountPolicy) {
+        checkType(accountPolicy, JPAAccountPolicy.class);
+        this.accountPolicy = (JPAAccountPolicy) accountPolicy;
+    }
+
+    @Override
+    public PasswordPolicy getPasswordPolicy() {
+        return passwordPolicy;
+    }
+
+    @Override
+    public void setPasswordPolicy(final PasswordPolicy passwordPolicy) {
+        checkType(passwordPolicy, JPAPasswordPolicy.class);
+        this.passwordPolicy = (JPAPasswordPolicy) passwordPolicy;
+    }
+
+    @Override
+    public SyncPolicy getSyncPolicy() {
+        return syncPolicy;
+    }
+
+    @Override
+    public void setSyncPolicy(final SyncPolicy syncPolicy) {
+        checkType(syncPolicy, JPASyncPolicy.class);
+        this.syncPolicy = (JPASyncPolicy) syncPolicy;
+    }
+
+    @Override
+    public Set<ConnConfProperty> getConnInstanceConfiguration() {
+        return StringUtils.isBlank(jsonConf)
+                ? Collections.<ConnConfProperty>emptySet()
+                : new HashSet<>(Arrays.asList(POJOHelper.deserialize(jsonConf, ConnConfProperty[].class)));
+    }
+
+    @Override
+    public void setConnInstanceConfiguration(final Set<ConnConfProperty> properties) {
+        jsonConf = POJOHelper.serialize(new HashSet<>(properties));
+    }
+
+    @Override
+    public String getSerializedUSyncToken() {
+        return userializedSyncToken;
+    }
+
+    @Override
+    public SyncToken getUsyncToken() {
+        return userializedSyncToken == null
+                ? null
+                : POJOHelper.deserialize(userializedSyncToken, SyncToken.class);
+    }
+
+    @Override
+    public void setUsyncToken(final SyncToken syncToken) {
+        this.userializedSyncToken = syncToken == null ? null : POJOHelper.serialize(syncToken);
+    }
+
+    @Override
+    public String getSerializedRSyncToken() {
+        return rserializedSyncToken;
+    }
+
+    @Override
+    public SyncToken getRsyncToken() {
+        return rserializedSyncToken == null
+                ? null
+                : POJOHelper.deserialize(rserializedSyncToken, SyncToken.class);
+    }
+
+    @Override
+    public void setRsyncToken(final SyncToken syncToken) {
+        this.rserializedSyncToken = syncToken == null ? null : POJOHelper.serialize(syncToken);
+    }
+
+    @Override
+    public List<String> getPropagationActionsClassNames() {
+        return propagationActionsClassNames;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPALogger.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPALogger.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPALogger.java
new file mode 100644
index 0000000..c20856d
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPALogger.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.syncope.common.lib.types.LoggerLevel;
+import org.apache.syncope.common.lib.types.LoggerType;
+import org.apache.syncope.persistence.api.entity.Logger;
+
+@Entity
+@Table(name = JPALogger.TABLE)
+public class JPALogger extends AbstractEntity<String> implements Logger {
+
+    private static final long serialVersionUID = 943012777014416027L;
+
+    public static final String TABLE = "SyncopeLogger";
+
+    @Id
+    @Column(name = "logName")
+    private String name;
+
+    @Column(name = "logLevel", nullable = false)
+    @Enumerated(EnumType.STRING)
+    private LoggerLevel level;
+
+    @Column(name = "logType", nullable = false)
+    @Enumerated(EnumType.STRING)
+    private LoggerType type;
+
+    @Override
+    public String getKey() {
+        return name;
+    }
+
+    @Override
+    public void setKey(final String name) {
+        this.name = name;
+    }
+
+    @Override
+    public LoggerLevel getLevel() {
+        return level;
+    }
+
+    @Override
+    public void setLevel(final LoggerLevel level) {
+        this.level = level;
+    }
+
+    @Override
+    public LoggerType getType() {
+        return type;
+    }
+
+    @Override
+    public void setType(final LoggerType type) {
+        this.type = type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/556d5186/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPANotification.java
----------------------------------------------------------------------
diff --git a/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPANotification.java b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPANotification.java
new file mode 100644
index 0000000..8f93dbd
--- /dev/null
+++ b/syncope620/server/persistence-jpa/src/main/java/org/apache/syncope/persistence/jpa/entity/JPANotification.java
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.persistence.jpa.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.CollectionTable;
+import javax.persistence.Column;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Table;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import org.apache.syncope.common.lib.types.IntMappingType;
+import org.apache.syncope.common.lib.types.TraceLevel;
+import org.apache.syncope.persistence.api.entity.Notification;
+import org.apache.syncope.persistence.jpa.validation.entity.NotificationCheck;
+
+@Entity
+@Table(name = JPANotification.TABLE)
+@NotificationCheck
+public class JPANotification extends AbstractEntity<Long> implements Notification {
+
+    private static final long serialVersionUID = 3112582296912757537L;
+
+    public static final String TABLE = "Notification";
+
+    @Id
+    private Long id;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name = "Notification_events",
+            joinColumns =
+            @JoinColumn(name = "Notification_id", referencedColumnName = "id"))
+    @Column(name = "events")
+    private List<String> events;
+
+    private String userAbout;
+
+    private String roleAbout;
+
+    private String recipients;
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name = "Notification_staticRecipients",
+            joinColumns =
+            @JoinColumn(name = "Notification_id", referencedColumnName = "id"))
+    @Column(name = "staticRecipients")
+    private List<String> staticRecipients;
+
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private IntMappingType recipientAttrType;
+
+    @NotNull
+    private String recipientAttrName;
+
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer selfAsRecipient;
+
+    @NotNull
+    private String sender;
+
+    @NotNull
+    private String subject;
+
+    @NotNull
+    private String template;
+
+    @NotNull
+    @Enumerated(EnumType.STRING)
+    private TraceLevel traceLevel;
+
+    @Column(nullable = false)
+    @Basic
+    @Min(0)
+    @Max(1)
+    private Integer active;
+
+    public JPANotification() {
+        events = new ArrayList<>();
+        staticRecipients = new ArrayList<>();
+        selfAsRecipient = getBooleanAsInteger(false);
+        active = getBooleanAsInteger(true);
+        traceLevel = TraceLevel.ALL;
+    }
+
+    @Override
+    public Long getKey() {
+        return id;
+    }
+
+    @Override
+    public String getUserAbout() {
+        return userAbout;
+    }
+
+    @Override
+    public void setUserAbout(final String userAbout) {
+        this.userAbout = userAbout;
+    }
+
+    @Override
+    public String getRoleAbout() {
+        return roleAbout;
+    }
+
+    @Override
+    public void setRoleAbout(final String roleAbout) {
+        this.roleAbout = roleAbout;
+    }
+
+    @Override
+    public String getRecipients() {
+        return recipients;
+    }
+
+    @Override
+    public void setRecipients(final String recipients) {
+        this.recipients = recipients;
+    }
+
+    @Override
+    public String getRecipientAttrName() {
+        return recipientAttrName;
+    }
+
+    @Override
+    public void setRecipientAttrName(final String recipientAttrName) {
+        this.recipientAttrName = recipientAttrName;
+    }
+
+    @Override
+    public IntMappingType getRecipientAttrType() {
+        return recipientAttrType;
+    }
+
+    @Override
+
+    public void setRecipientAttrType(final IntMappingType recipientAttrType) {
+        this.recipientAttrType = recipientAttrType;
+    }
+
+    @Override
+    public List<String> getEvents() {
+        return events;
+    }
+
+    @Override
+    public boolean addEvent(final String event) {
+        return event != null && !events.contains(event) && events.add(event);
+    }
+
+    @Override
+    public boolean removeEvent(final String event) {
+        return event != null && events.remove(event);
+    }
+
+    @Override
+    public List<String> getStaticRecipients() {
+        return staticRecipients;
+    }
+
+    @Override
+    public boolean addStaticRecipient(final String staticRecipient) {
+        return staticRecipient != null && !staticRecipients.contains(staticRecipient)
+                && staticRecipients.add(staticRecipient);
+    }
+
+    @Override
+    public boolean removeStaticRecipient(final String staticRecipient) {
+        return staticRecipient != null && staticRecipients.remove(staticRecipient);
+    }
+
+    @Override
+    public boolean isSelfAsRecipient() {
+        return isBooleanAsInteger(selfAsRecipient);
+    }
+
+    @Override
+    public void setSelfAsRecipient(final boolean selfAsRecipient) {
+        this.selfAsRecipient = getBooleanAsInteger(selfAsRecipient);
+    }
+
+    @Override
+    public String getSender() {
+        return sender;
+    }
+
+    @Override
+    public void setSender(final String sender) {
+        this.sender = sender;
+    }
+
+    @Override
+    public String getSubject() {
+        return subject;
+    }
+
+    @Override
+
+    public void setSubject(final String subject) {
+        this.subject = subject;
+    }
+
+    @Override
+    public String getTemplate() {
+        return template;
+    }
+
+    @Override
+    public void setTemplate(final String template) {
+        this.template = template;
+    }
+
+    @Override
+    public TraceLevel getTraceLevel() {
+        return traceLevel;
+    }
+
+    @Override
+    public void setTraceLevel(final TraceLevel traceLevel) {
+        this.traceLevel = traceLevel;
+    }
+
+    @Override
+    public boolean isActive() {
+        return isBooleanAsInteger(active);
+    }
+
+    @Override
+    public void setActive(final boolean active) {
+        this.active = getBooleanAsInteger(active);
+    }
+}