Skip to content
Snippets Groups Projects
Commit 91164ab9 authored by srosse's avatar srosse
Browse files

CL-220: fix HQL query in notifications to retrieve publisher without...

CL-220: fix HQL query in notifications to retrieve publisher without sub-identifier (specific to Oracle)
parent 196aaab7
No related branches found
No related tags found
No related merge requests found
...@@ -613,15 +613,24 @@ public class NotificationsManagerImpl extends NotificationsManager implements Us ...@@ -613,15 +613,24 @@ public class NotificationsManagerImpl extends NotificationsManager implements Us
* subidentifier. * subidentifier.
*/ */
private Publisher getPublisher(String resName, Long resId, String subidentifier, boolean forUpdate) { private Publisher getPublisher(String resName, Long resId, String subidentifier, boolean forUpdate) {
StringBuilder q = new StringBuilder(); StringBuilder q = new StringBuilder();
q.append("select pub from ").append(PublisherImpl.class.getName()).append(" pub ") 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() TypedQuery<Publisher> query = DBFactory.getInstance().getCurrentEntityManager()
.createQuery(q.toString(), Publisher.class) .createQuery(q.toString(), Publisher.class)
.setParameter("resName", resName) .setParameter("resName", resName)
.setParameter("resId", resId.longValue()) .setParameter("resId", resId.longValue());
.setParameter("subidentifier", subidentifier);
if(StringHelper.containsNonWhitespace(subidentifier)) {
query.setParameter("subidentifier", subidentifier);
}
if(forUpdate) { if(forUpdate) {
query.setLockMode(LockModeType.PESSIMISTIC_WRITE); query.setLockMode(LockModeType.PESSIMISTIC_WRITE);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment