From 91164ab9c9c704d63f801323af7b28a73a7baaac Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 29 Apr 2013 16:03:28 +0200 Subject: [PATCH] CL-220: fix HQL query in notifications to retrieve publisher without sub-identifier (specific to Oracle) --- .../notifications/NotificationsManagerImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/olat/notifications/NotificationsManagerImpl.java b/src/main/java/org/olat/notifications/NotificationsManagerImpl.java index bf513b721f5..d27a6406d96 100644 --- a/src/main/java/org/olat/notifications/NotificationsManagerImpl.java +++ b/src/main/java/org/olat/notifications/NotificationsManagerImpl.java @@ -613,15 +613,24 @@ public class NotificationsManagerImpl extends NotificationsManager implements Us * subidentifier. */ private Publisher getPublisher(String resName, Long resId, String subidentifier, boolean forUpdate) { + StringBuilder q = new StringBuilder(); q.append("select pub from ").append(PublisherImpl.class.getName()).append(" pub ") - .append(" where pub.resName=:resName and pub.resId = :resId and pub.subidentifier = :subidentifier"); + .append(" where pub.resName=:resName and pub.resId = :resId"); + if(StringHelper.containsNonWhitespace(subidentifier)) { + q.append(" and pub.subidentifier=:subidentifier"); + } else { + q.append(" and (pub.subidentifier='' or pub.subidentifier is null)"); + } TypedQuery<Publisher> query = DBFactory.getInstance().getCurrentEntityManager() .createQuery(q.toString(), Publisher.class) .setParameter("resName", resName) - .setParameter("resId", resId.longValue()) - .setParameter("subidentifier", subidentifier); + .setParameter("resId", resId.longValue()); + + if(StringHelper.containsNonWhitespace(subidentifier)) { + query.setParameter("subidentifier", subidentifier); + } if(forUpdate) { query.setLockMode(LockModeType.PESSIMISTIC_WRITE); } -- GitLab