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 2019/10/23 12:52:24 UTC
[syncope] branch master updated: [SYNCOPE-1461] All works finally
with MySQL 8.0.18
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 5e7c289 [SYNCOPE-1461] All works finally with MySQL 8.0.18
5e7c289 is described below
commit 5e7c289802420d6c248a63f2137fcfd656eae35c
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Oct 23 14:45:07 2019 +0200
[SYNCOPE-1461] All works finally with MySQL 8.0.18
---
.../persistence/jpa/dao/AbstractJPAJSONAnyDAO.java | 23 +++++++++++-
.../core/persistence/jpa/dao/MyJPAJSONAnyDAO.java | 42 ----------------------
.../core/persistence/jpa/dao/PGJPAJSONAnyDAO.java | 27 --------------
.../src/test/resources/domains/MasterContent.xml | 2 +-
.../main/resources/audit/audit_mysql_innodb.sql | 2 +-
pom.xml | 2 +-
.../systemadministration/dbms.adoc | 3 --
7 files changed, 25 insertions(+), 76 deletions(-)
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractJPAJSONAnyDAO.java b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractJPAJSONAnyDAO.java
index ed76790..90cd273 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractJPAJSONAnyDAO.java
+++ b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractJPAJSONAnyDAO.java
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.StringJoiner;
import java.util.regex.Pattern;
import javax.persistence.Query;
import org.apache.commons.jexl3.parser.Parser;
@@ -180,7 +181,27 @@ abstract class AbstractJPAJSONAnyDAO extends AbstractDAO<AbstractEntity> impleme
return attrValues;
}
- protected abstract List<Object> findByDerAttrValue(String table, Map<String, List<Object>> clauses);
+ @SuppressWarnings("unchecked")
+ protected List<Object> findByDerAttrValue(
+ final String table,
+ final Map<String, List<Object>> clauses) {
+
+ StringJoiner actualClauses = new StringJoiner(" AND id IN ");
+ List<Object> queryParams = new ArrayList<>();
+
+ clauses.forEach((clause, parameters) -> {
+ actualClauses.add(clause);
+ queryParams.addAll(parameters);
+ });
+
+ Query query = entityManager().createNativeQuery(
+ "SELECT DISTINCT id FROM " + table + " u WHERE id IN " + actualClauses.toString());
+ for (int i = 0; i < queryParams.size(); i++) {
+ query.setParameter(i + 1, queryParams.get(i));
+ }
+
+ return query.getResultList();
+ }
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONAnyDAO.java b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONAnyDAO.java
index ec3ee70..a5c2d93 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONAnyDAO.java
+++ b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONAnyDAO.java
@@ -18,13 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
-import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -79,40 +73,4 @@ public class MyJPAJSONAnyDAO extends AbstractJPAJSONAnyDAO {
return "JSON_CONTAINS(plainAttrs, '" + POJOHelper.serialize(List.of(container)) + "')";
}
}
-
- /**
- * {@inheritDoc}
- *
- * This method is a workaround for a bug experienced up to MySQL 8.0.15, where the correct implementation (as shown
- * in {@link PGJPAJSONAnyDAO#findByDerAttrValue(java.lang.String, java.util.Map)} generates a core dump.
- */
- @Override
- @SuppressWarnings("unchecked")
- protected List<Object> findByDerAttrValue(
- final String table,
- final Map<String, List<Object>> clauses) {
-
- if (clauses.isEmpty()) {
- return List.of();
- }
-
- Set<Object> result = new HashSet<>();
- AtomicReference<Boolean> first = new AtomicReference<>(Boolean.TRUE);
- clauses.forEach((clause, parameters) -> {
- Query query = entityManager().createNativeQuery(StringUtils.replaceIgnoreCase(clause, "DISTINCT", ""));
- for (int i = 0; i < parameters.size(); i++) {
- query.setParameter(i + 1, parameters.get(i));
- }
-
- Set<Object> local = new HashSet<>(query.getResultList());
- if (first.get()) {
- result.addAll(local);
- first.set(Boolean.FALSE);
- } else {
- result.retainAll(local);
- }
- });
-
- return new ArrayList<>(result);
- }
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnyDAO.java b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnyDAO.java
index dbc7bce..a9673c0 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnyDAO.java
+++ b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnyDAO.java
@@ -18,11 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.StringJoiner;
-import javax.persistence.Query;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.core.persistence.api.entity.AnyUtils;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
@@ -71,27 +67,4 @@ public class PGJPAJSONAnyDAO extends AbstractJPAJSONAnyDAO {
return "plainAttrs @> '" + POJOHelper.serialize(List.of(container)) + "'::jsonb";
}
}
-
- @Override
- @SuppressWarnings("unchecked")
- protected List<Object> findByDerAttrValue(
- final String table,
- final Map<String, List<Object>> clauses) {
-
- StringJoiner actualClauses = new StringJoiner(" AND id IN ");
- List<Object> queryParams = new ArrayList<>();
-
- clauses.forEach((clause, parameters) -> {
- actualClauses.add(clause);
- queryParams.addAll(parameters);
- });
-
- Query query = entityManager().createNativeQuery(
- "SELECT DISTINCT id FROM " + table + " u WHERE id IN " + actualClauses.toString());
- for (int i = 0; i < queryParams.size(); i++) {
- query.setParameter(i + 1, queryParams.get(i));
- }
-
- return query.getResultList();
- }
}
diff --git a/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
index 32b4d34..5c321dc 100644
--- a/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa-json/src/test/resources/domains/MasterContent.xml
@@ -424,7 +424,7 @@ under the License.
<!-- push policies -->
<PushPolicy id="fb6530e5-892d-4f47-a46b-180c5b6c5c83" description="a push policy" conflictResolutionAction="IGNORE"/>
<Implementation id="TestPushCorrelationRule" type="PUSH_CORRELATION_RULE" engine="JAVA"
- body='{"@class":"org.apache.syncope.common.lib.policy.DefaultPushCorrelationRuleConf","name":"org.apache.syncope.common.lib.policy.DefaultPushCorrelationRuleConf","schemas":["email"]}'/>
+ body='{"@class":"org.apache.syncope.common.lib.policy.DefaultPushCorrelationRuleConf","name":"org.apache.syncope.common.lib.policy.DefaultPushCorrelationRuleConf","schemas":["surname"]}'/>
<PushCorrelationRuleEntity id="24463935-32a0-4272-bc78-04d6d0adc69e" pushPolicy_id="fb6530e5-892d-4f47-a46b-180c5b6c5c83"
anyType_id="USER" implementation_id="TestPushCorrelationRule"/>
diff --git a/core/persistence-jpa/src/main/resources/audit/audit_mysql_innodb.sql b/core/persistence-jpa/src/main/resources/audit/audit_mysql_innodb.sql
index 4d8426c..0376c1f 100644
--- a/core/persistence-jpa/src/main/resources/audit/audit_mysql_innodb.sql
+++ b/core/persistence-jpa/src/main/resources/audit/audit_mysql_innodb.sql
@@ -19,6 +19,6 @@ CREATE TABLE IF NOT EXISTS SYNCOPEAUDIT (
EVENT_DATE TIMESTAMP,
LOGGER_LEVEL VARCHAR(255) NOT NULL,
LOGGER VARCHAR(255) NOT NULL,
- MESSAGE TEXT NOT NULL,
+ MESSAGE LONGTEXT NOT NULL,
THROWABLE TEXT
) ENGINE=InnoDB;
diff --git a/pom.xml b/pom.xml
index bc4ad3e..6f93328 100644
--- a/pom.xml
+++ b/pom.xml
@@ -519,7 +519,7 @@ under the License.
<docker.mariadb.version>10.4</docker.mariadb.version>
<jdbc.postgresql.version>42.2.8</jdbc.postgresql.version>
- <jdbc.mysql.version>8.0.16</jdbc.mysql.version>
+ <jdbc.mysql.version>8.0.18</jdbc.mysql.version>
<jdbc.mariadb.version>2.4.1</jdbc.mariadb.version>
<jdbc.mssql.version>7.2.2.jre</jdbc.mssql.version>
<jdbc.oracle.version>19.3.0.0</jdbc.oracle.version>
diff --git a/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc b/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
index 86c9951..e940085 100644
--- a/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
+++ b/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
@@ -195,9 +195,6 @@ This assumes that you have a MySQL instance running on localhost, listening on i
With the configurations reported below, Apache Syncope will leverage the
https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html[JSON_TABLE^] function.
-[CAUTION]
-This MySQL feature does not appear yet to be production-ready, use it with caution.
-
[NOTE]
Apache Syncope {docVersion} is verified with MySQL server >= 8.0 and JDBC driver >= {mysqlJDBC}.