martinweiler commented on code in PR #4273:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4273#discussion_r3335472147


##########
addons/common/jbpm-usertask-storage-jpa/src/main/java/org/jbpm/usertask/jpa/model/UserTaskInstanceEntity.java:
##########
@@ -29,25 +29,33 @@
 import jakarta.persistence.*;
 
 @Entity
-@NamedQuery(name = UserTaskInstanceEntity.GET_INSTANCES_BY_IDENTITY,
-        query = "select userTask from UserTaskInstanceEntity userTask " +
-                "left join userTask.adminGroups adminGroup " +
-                "left join userTask.potentialGroups potentialGroup " +
-                "where :userId member of userTask.adminUsers " +
-                "or adminGroup in (:roles) " +
-                "or userTask.actualOwner = :userId " +
-                "or (userTask.actualOwner is null " + // checking if task is 
not reserved, we cannot check by status since lifecycle can be customized
-                "and :userId not member of userTask.excludedUsers " +
-                "and (:userId member of userTask.potentialUsers or 
potentialGroup in (:roles)" +
-                "))")
 @NamedNativeQuery(
         name = UserTaskInstanceEntity.DELETE_BY_ID,
         query = "delete from jbpm_user_tasks where id = :taskId")
 @Table(name = "jbpm_user_tasks")
 public class UserTaskInstanceEntity {
-    public static final String GET_INSTANCES_BY_IDENTITY = 
"UserTaskInstanceEntity.GetInstanceByIdentity";
     public static final String DELETE_BY_ID = 
"UserTaskInstanceEntity.DeleteById";
 
+    // Base query for finding instances by identity (without status filter)
+    public static final String BASE_IDENTITY_QUERY =
+            "select userTask from UserTaskInstanceEntity userTask " +
+                    "left join userTask.adminGroups adminGroup " +
+                    "left join userTask.potentialGroups potentialGroup " +
+                    "where (:userId member of userTask.adminUsers " +
+                    "or adminGroup in (:roles) " +
+                    "or userTask.actualOwner = :userId " +
+                    "or (userTask.actualOwner is null " + // checking if task 
is not reserved, we cannot check by status since lifecycle can be customized
+                    "and :userId not member of userTask.excludedUsers " +
+                    "and (:userId member of userTask.potentialUsers or 
potentialGroup in (:roles)))) " +
+                    "and (cast(:processId as string) is null or 
userTask.processInfo.processId = :processId) " +
+                    "and (cast(:processInstanceId as string) is null or 
userTask.processInfo.processInstanceId = :processInstanceId)";
+
+    // TaskName filter clause - case-insensitive (conditional to avoid bytea 
issues)
+    public static final String TASKNAME_FILTER_CLAUSE = " and 
lower(userTask.taskName) like lower(concat('%', :taskName, '%'))";

Review Comment:
   You are raising some valid concerns about potential performance issues. We 
also don't have an actual request to support `like` queries.
   
   @GopikaReghunath please adjust the code accordingly. Thanks!



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to