[OpenNMS/opennms] 787780: NMS-20161: Apply criteria fetch modes after the di...

OpenNMS Machine User via opennms-cvs <[email protected]>
Newsgroups gmane.network.opennms.cvs
Message-ID <OpenNMS/opennms/push/refs/heads/merge-foundation/foundation-2023-to-foundation-2024/[email protected]>
  Branch: refs/heads/merge-foundation/foundation-2023-to-foundation-2024
  Home:   https://github.com/OpenNMS/opennms
  Commit: 7877808196b98281f68c6770d32899d7cd1ebf72
      https://github.com/OpenNMS/opennms/commit/7877808196b98281f68c6770d32899d7cd1ebf72
  Author: Marshall Massengill <[email protected]>
  Date:   2026-09-01 (Tue, 01 Sep 2026)

  Changed paths:
    M opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/HibernateCriteriaConverter.java
    M opennms-dao/src/test/java/org/opennms/netmgt/dao/hibernate/HibernateCriteriaConverterIT.java
    M opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/AlarmRestServiceBase.java
    M opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/AlarmStatsRestService.java

  Log Message:
  -----------
  NMS-20161: Apply criteria fetch modes after the distinct rewrite for v1 /rest/alarms  (#8762)

* NMS-20161: Apply criteria fetch modes after the distinct rewrite

HibernateCriteriaVisitor.visitFetch() set fetch modes directly on
m_criteria, but getCriteria() then implements distinct() by demoting that
criteria to an id-only subquery and building a new outer criteria. The
fetch modes went with the subquery, where Hibernate ignores them anyway
once a projection is set, so any criteria combining fetch(EAGER) with
distinct() silently got no join.

For v1 /rest/alarms this left OnmsAlarm.lastEvent as a lazy proxy read in
a separate statement per alarm, during hydration and after the alarm rows
had been read. An event deleted in that window by auto-clean reduction
raises ObjectNotFoundException, which OnmsAlarm.setLastEvent swallows, so
the broken proxy escapes the DAO and fails later inside the serializer,
truncating the response body.

Hold the fetch modes and apply them to the outer criteria after the
rewrite, the way m_orders already is.

* NMS-20161: Remove the unresolvable firstEvent fetch from the v1 alarm criteria

OnmsAlarm has no firstEvent property. Its only OnmsEvent association is
lastEvent; firstEventTime is a plain column. Hibernate ignores fetch modes
whose path it cannot resolve, so this threw nothing before and throws
nothing now, but the preceding commit makes these declarations reach the
query, and a live fetch mode that resolves to nothing is a trap for the
next reader.

* NMS-20161: Keep to-many fetches out of the distinct outer criteria

Applying the held fetch modes to the outer criteria makes them live for
every association, not just the to-one ones the alarm criteria needs. A
join fetch of a collection returns one outer row per element, which would
undo the distinct() rewrite it is applied after and leave setMaxResults
counting joined rows rather than entities. No caller fetches a collection
today, but the declaration now reaches the query, so the trap is real.

Ask the session factory whether the path is collection-valued and skip
those fetches, leaving the association to load the way it did when the
fetch modes still went to the subquery. Answering that needs a
SessionFactory, so the two entry points that take a Session hand theirs to
the visitor; the detached overloads, which nothing calls, still apply
every fetch mode.


  Commit: 9b7432c5311f09a7af0de97f5ddb6e0d8c7f397e
      https://github.com/OpenNMS/opennms/commit/9b7432c5311f09a7af0de97f5ddb6e0d8c7f397e
  Author: Marshall Massengill <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    M opennms-webapp-rest/src/main/java/org/opennms/web/rest/v1/NotificationRestService.java
    M opennms-webapp-rest/src/test/java/org/opennms/web/rest/v1/NotificationRestServiceIT.java

  Log Message:
  -----------
  NMS-20283: Count notifications, not deliveries, in the notification summary (#8834)

/notifications/summary derived userUnacknowledgedCount, teamUnacknowledgedCount
and the newest-notifications list from a criteria join to usersNotified, and
countMatching counts join rows. A notification carries one usersNotified row per
notification method, so a user notified by both email and pager was counted
twice and appeared twice in the list. On a real install the personal count came
back larger than the total unacknowledged count, and the header badge disagreed
with the notification list it links to.

Marking the three criteria distinct() moves the join into a subquery on the
notification id, so both the counts and the list are per notification.

This changes a published REST field: installs whose users have several
notification methods configured will see these counts drop to the real number
of notifications.


  Commit: 577fde7be66f0b65056c1c403c6ee0e992d50340
      https://github.com/OpenNMS/opennms/commit/577fde7be66f0b65056c1c403c6ee0e992d50340
  Author: Chandra Gorantla <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    M opennms-base-assembly/src/main/filtered/etc/report-templates/AssetManagementMaintExpired.jrxml
    M opennms-base-assembly/src/main/filtered/etc/report-templates/AssetManagementMaintStrategy.jrxml

  Log Message:
  -----------
  NMS-20245: Fix SQL injection in Asset Management JasperReports (#8832)

Bind the user-prompted DATE_FORMAT/threshold params ($P{}) instead of literal
$P!{} substitution in AssetManagementMaintExpired and AssetManagementMaintStrategy.


  Commit: cfd526d22ad42934f7d61fc8666703a85f9e353d
      https://github.com/OpenNMS/opennms/commit/cfd526d22ad42934f7d61fc8666703a85f9e353d
  Author: CI/CD System <[email protected]>
  Date:   2026-09-02 (Wed, 02 Sep 2026)

  Changed paths:
    M opennms-base-assembly/src/main/filtered/etc/report-templates/AssetManagementMaintExpired.jrxml
    M opennms-base-assembly/src/main/filtered/etc/report-templates/AssetManagementMaintStrategy.jrxml

  Log Message:
  -----------
  Merge remote-tracking branch 'origin/foundation-2023' into foundation-2024


Compare: https://github.com/OpenNMS/opennms/compare/540e5118303a...cfd526d22ad4

To unsubscribe from these emails, change your notification settings at https://github.com/OpenNMS/opennms/settings/notifications


_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/wiki/index.php?page=MailingListFaq
opennms-cvs mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.