Skip to content

Auto assignments with target filter queries like "type.id=not=XYZ" doesn't match targets without target type (with EclipseLink only) #2758

Open

Description

@avgustinmm

Issue:

  • I have 4 devices: 2 of type NOT_XYZ and 2 without type.
  • I create target filter with "type.id=not=XYZ" and assign a distribution set (compatible with all devices)
  • Expected: all 4 devices should be involved
  • Result: only these of type NOT_XYZ are involved. Targets without type are not.

After some debug:

  • this behavior is observed with EclipseLink JPA provider only. With Hibernate it seems as expected - so, it seems the bug comes from there
  • JpaTargetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable creates the following SQL queries:
# EclipseLink
SELECT DISTINCT * FROM sp_target t1 
  LEFT OUTER JOIN sp_target_type t0 ON (t0.id = t1.target_type) 
  LEFT OUTER JOIN (sp_target_type_ds_type t4 JOIN sp_distribution_set_type t2 ON (t2.id = t4.distribution_set_type)) ON (t4.target_type = t0.id), 
  sp_target_type t3 
  WHERE (((((t3.id IS NULL) OR (t1.target_type <> ?)) AND ((t1.target_type IS NULL) OR (t2.id = ?))) AND (t1.tenant = ?)) AND ((t3.id = t1.target_type) AND (t3.tenant = ?))) LIMIT ?, ?
# Hibernate
select distinct * from sp_target jt1_0 
  left join sp_target_type tt1_0 on tt1_0.id=jt1_0.target_type and tt1_0.tenant = ? 
  left join sp_target_type tt2_0 on tt2_0.id=jt1_0.target_type and tt2_0.tenant = ? 
  left join sp_target_type_ds_type dst1_0 on tt2_0.id=dst1_0.target_type
  where jt1_0.tenant = ? and (tt1_0.id is null or tt1_0.id<>?) and (jt1_0.target_type is null or dst1_0.distribution_set_type=?) limit ?,?
  • from the EclipseLink query it seems that the problem is that (t3.tenant = ?) check requires that there is a target type available
  • so, it seems that it is related to EclipseLink and its tenancy support

PS: added a PR with a tests that shows that behavior - #2759 -> TargetManagementSearchTest#shouldFindTargetsWithoutTypeByTypeIdNot

Activity

  1. added 2 commits that reference this issue on Oct 16, 2025
  2. Basavaraj8143 commented on Nov 8, 2026

    @Basavaraj8143

    Hi @avgustinmm,

    I'd like to investigate and work on the underlying EclipseLink issue reported here.

    I noticed that PR #2759 added the test case demonstrating the behavior, but the underlying query issue still appears unresolved.

    I plan to investigate the query generation in JpaTargetManagement, particularly the interaction between target-type joins and tenant filtering, and propose a fix that preserves tenant isolation.

    Is this issue still open for contributions?

    Thanks!

  3. avgustinmm commented on Nov 9, 2026

    @avgustinmm
    ContributorAuthor

    Hi @Basavaraj8143,
    this issue was created to keep us aware of this EclipseLink behaviour. The test (TargetManagementSearchTest#shouldFindTargetsWithoutTypeByTypeIdNot) was made to notify us if EclipseLink fix it eventually - if they fix it - it will fail.
    The test still passed so it seems it is still valid.
    What's open for contribution regarding this issue on our side is eventually to find out a workaround to serve such kind of filters in proper manner. However, if this is an issue in EclipseLink (and Hibernate behaviour is the correct one) the best possible resolution would be to be fixed in EclipseLink - not workaround here.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions