Skip to content

Fix target group assignment with RSQL negation filters (e.g. tag!=tag…#3116

Open
strailov wants to merge 3 commits into
eclipse-hawkbit:masterfrom
boschglobal:fix/assign_target_groups_with_rsql_against_mysql
Open

Fix target group assignment with RSQL negation filters (e.g. tag!=tag…#3116
strailov wants to merge 3 commits into
eclipse-hawkbit:masterfrom
boschglobal:fix/assign_target_groups_with_rsql_against_mysql

Conversation

@strailov
Copy link
Copy Markdown
Contributor

@strailov strailov commented Jun 4, 2026

…1) failing on EclipseLink/MySQL

  • EclipseLink's UpdateAllQuery cannot handle NOT EXISTS subqueries with inherited @id from @MappedSuperclass — generates invalid SQL (cross-join, missing ManyToMany join table)
  • When RSQL contains negation (!=, =out=, =notlike=), use chunked SELECT+UPDATE approach that bypasses the EclipseLink bug
  • Positive RSQL filters continue using the direct single-query CriteriaUpdate path
  • Chunk size configurable via hawkbit.target-group.assign.chunk-size (default: 1000)

…1) failing on EclipseLink/MySQL

Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
@strailov strailov requested a review from avgustinmm June 4, 2026 13:22
update.where(update.getRoot().get(AbstractJpaBaseEntity_.ID).in(chunk));
entityManager.createQuery(update).executeUpdate();
}
offset += CHUNK_SIZE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there granted db will return as much as possible up to CHUNK_SIZE? or db could decide to return less (as for instance InputStream with buffer works?) - maybe not
so better increment with the chunk.size() and exit if empty, not when != CHUNK_SIZE

strailov added 2 commits June 5, 2026 09:25
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
// BUG Reported: https://github.com/eclipse-ee4j/eclipselink/issues/2757
// Hibernate: applies predicate directly to the UPDATE root — Hibernate handles
// NOT EXISTS subqueries correctly in CriteriaUpdate context. So this problem does not exist there.
if (containsNegation(rsql)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (containsNegation(rsql)) {
if (Jpa.JPA_VENDOR == Jpa.JpaVendor.ECLIPSELINK && containsNegation(rsql)) {


List<Long> chunk;
int offset = 0;
final int CHUNK_SIZE = assignTargetGroupChunkSize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHUNK_SIZE -> chunkSize, and it's not actually needed - you could use assignTargetGroupChunkSize directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants