Skip to content

Fix RSQL filter in batch update query in assign target group#3107

Merged
strailov merged 5 commits into
eclipse-hawkbit:masterfrom
boschglobal:fix/target_groups_on_not_equals_on_set_fields
Jun 2, 2026
Merged

Fix RSQL filter in batch update query in assign target group#3107
strailov merged 5 commits into
eclipse-hawkbit:masterfrom
boschglobal:fix/target_groups_on_not_equals_on_set_fields

Conversation

@strailov
Copy link
Copy Markdown
Contributor

@strailov strailov commented May 28, 2026

Refactor assignTargetGroupWithRsql to use a subquery-based approach
(WHERE id IN (SELECT id FROM ... WHERE <rsql_predicate>))
instead of applying the RSQL predicate directly to the CriteriaUpdate root.

The NOT EXISTS subquery generated by SpecificationBuilder.notEqualInLike for negated set attribute filters (tag!=, tag=out=) requires JOINs that do not work correctly when attached to an UPDATE root in EclipseLink's UpdateAllQuery. By wrapping the RSQL spec in a SELECT subquery, all JOINs and correlated subqueries execute in a proper SELECT context

Add integration test verifying tag!= filter works correctly
when assigning target groups via RSQL.

Old approach generated the following query :

UPDATE sp_target t
SET t.group_ = 'FilteredGroup'
WHERE NOT EXISTS (
    SELECT t2 FROM sp_target t2
    LEFT JOIN sp_target_tags tt ON t2.id = tt.target_id
    LEFT JOIN sp_tag tag ON tt.tag_id = tag.id
    WHERE t2.id = t.id AND tag.name = 'tag1'
)

Which fails in EclipseLink — t.id correlation in the subquery references the UPDATE root, which EclipseLink's UpdateAllQuery can't resolve properly for inherited @id fields.

New Approach :

UPDATE sp_target t
SET t.group_ = 'FilteredGroup'
WHERE t.id IN (
    SELECT t1.id FROM sp_target t1
    WHERE NOT EXISTS (
        SELECT t2 FROM sp_target t2
        LEFT JOIN sp_target_tags tt ON t2.id = tt.target_id
        LEFT JOIN sp_tag tag ON tt.tag_id = tag.id
        WHERE t2.id = t1.id AND tag.name = 'tag1'
    )
)

Also this approach did not work for hibernate, so when using hibernate the old approach is applied.
Meaniong : EclipseLink takes the subquery path (WHERE id IN (SELECT ...))to avoid UpdateAllQuery's @id resolution bug.
While Hibernate takes the direct predicate path for optimal single-statement execution.

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
strailov added 2 commits May 28, 2026 15:57
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
@strailov strailov merged commit 7944550 into eclipse-hawkbit:master Jun 2, 2026
6 checks passed
@strailov strailov deleted the fix/target_groups_on_not_equals_on_set_fields branch June 2, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants