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

Marshall Massengill via opennms-cvs <[email protected]>
Newsgroups gmane.network.opennms.cvs
Message-ID <OpenNMS/opennms/push/refs/heads/mm/NMS-20161-smoke/[email protected]>
  Branch: refs/heads/mm/NMS-20161-smoke
  Home:   https://github.com/OpenNMS/opennms
  Commit: 9a02566a615b135083b889883044eeb70bdeb8e6
      https://github.com/OpenNMS/opennms/commit/9a02566a615b135083b889883044eeb70bdeb8e6
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 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

  Log Message:
  -----------
  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.


  Commit: b61e7bb24a4082fd9fe7724073059b004fdd1764
      https://github.com/OpenNMS/opennms/commit/b61e7bb24a4082fd9fe7724073059b004fdd1764
  Author: Marshall Massengill <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    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: 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.


Compare: https://github.com/OpenNMS/opennms/compare/5b4ec33de674...b61e7bb24a40

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.