Skip to content

Fix ColleagueResponse.find(): string identity comparisons and unbound :subjectAbbvs parameter - #2

Open
tarekabiramia wants to merge 2 commits into
UniTime:masterfrom
digipen-rnd:fix/colleague-response-hql
Open

Fix ColleagueResponse.find(): string identity comparisons and unbound :subjectAbbvs parameter#2
tarekabiramia wants to merge 2 commits into
UniTime:masterfrom
digipen-rnd:fix/colleague-response-hql

Conversation

@tarekabiramia

@tarekabiramia tarekabiramia commented Sep 1, 2026

Copy link
Copy Markdown

Two small bug fixes in ColleagueAddOn/JavaSource/org/unitime/colleague/model/ColleagueResponse.java, both hit on the Colleague Message Responses screen (UniTime 4.9 + Colleague add-on on Tomcat 10.1, MySQL).

1. != "" string identity comparisons make empty filters behave as real filters

find() guards its optional filters with x != "". That compares object references, and the filter values coming back from the HTTP session are runtime-constructed empty strings (the form only clears session attributes when the value is null), so the guard is true for empty input. The query then gains predicates like upper(rp.courseNumber) = upper('') and the screen returns zero rows until the user starts a fresh HTTP session.

Fixed by replacing the identity comparisons with !x.isEmpty() at all 8 sites the 4 whereHql builders and the 4 matching setParameter guards must change together, otherwise Hibernate throws on a parameter/query mismatch.

2. :subjectAbbvs predicate appended even when no subject list is bound

The query builder unconditionally appends rp.subjectCode in :subjectAbbvs, but the binder only calls setParameterList when the subject list is non-empty. Administrators reach find() with an empty subject set, so the clause was added with nothing bound and Hibernate threw QueryParameterException: could not locate named parameter [subjectAbbvs].

Fixed by guarding the builder with the same emptiness condition the binder uses: admins get no subject restriction (they see all rows), non-admin users keep their subject-area scoping.

tarekabiramia added 2 commits September 1, 2026 11:15
…Response.find()

Empty filter fields on the Colleague Message Responses screen are stored in
the HTTP session as "" (the form only clears attributes when null), and
`x != ""` compares object references — true for any runtime empty string.
The query then gains predicates like upper(courseNumber) = upper('') and
the screen shows zero rows until the user starts a new HTTP session.

All 8 sites (4 whereHql builders + 4 setParameter guards) change together,
otherwise Hibernate throws on a parameter/query mismatch.
The query builder unconditionally appended "rp.subjectCode in :subjectAbbvs",
but the binder only calls setParameterList when the list is non-empty.
Administrators get an empty subjects set from the action, so the clause was
added with nothing bound and Hibernate threw QueryParameterException
(':subjectAbbvs'). Guard the builder with the same emptiness condition the
binder uses — admins get no subject restriction (they see everything),
non-admins keep their scoping.
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.

1 participant