ilgrosso commented on code in PR #1438:
URL: https://github.com/apache/syncope/pull/1438#discussion_r3472239115


##########
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuditEventDAO.java:
##########
@@ -61,6 +60,37 @@ protected AuditEventCriteriaBuilder entityKey(final String 
entityKey) {
             return this;
         }
 
+        // '#' is used as LIKE escape char (instead of '\') for portability: a 
backslash inside a SQL
+        // string literal is mishandled by MySQL/MariaDB, and Oracle applies 
no default escape at all.
+        protected static String toLikePattern(final String value) {
+            return value.
+                    replace("#", "##").
+                    replace("%", "#%").
+                    replace("_", "#_").
+                    replace("*", "%");
+        }
+
+        public AuditEventCriteriaBuilder who(final Set<String> who, final 
List<Object> parameters) {
+            if (who != null && !who.isEmpty()) {

Review Comment:
   replace with Spring's `CollectionUtils#isEmpty`



##########
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAuditEventDAO.java:
##########
@@ -61,6 +60,37 @@ protected AuditEventCriteriaBuilder entityKey(final String 
entityKey) {
             return this;
         }
 
+        // '#' is used as LIKE escape char (instead of '\') for portability: a 
backslash inside a SQL
+        // string literal is mishandled by MySQL/MariaDB, and Oracle applies 
no default escape at all.
+        protected static String toLikePattern(final String value) {
+            return value.
+                    replace("#", "##").
+                    replace("%", "#%").
+                    replace("_", "#_").
+                    replace("*", "%");
+        }
+
+        public AuditEventCriteriaBuilder who(final Set<String> who, final 
List<Object> parameters) {
+            if (who != null && !who.isEmpty()) {
+                query.append(andIfNeeded()).append("(");
+                boolean first = true;
+                for (String value : who) {

Review Comment:
   Can't this loop be replaced by stream with map and `Collectors#joining`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to