From a7adf8429f9beb735698fc429076d0df8b9a0200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Tilve=20=C3=81lvaro?= Date: Fri, 12 Apr 2013 18:57:47 +0200 Subject: [PATCH] Bug #1610: Fix problem accessing company view with limited permissions When the user had restricted access to the company view, and the list of specific projects that he could read is empty, an HibernateQueryException was being raised. FEA: ItEr77S04BugFixing --- .../org/libreplan/business/orders/daos/OrderDAO.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderDAO.java index 9de3542a0..f8e563dc9 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderDAO.java @@ -442,12 +442,16 @@ public class OrderDAO extends IntegrationEntityDAO implements } else { String strQuery = "SELECT oa.order.id " + "FROM OrderAuthorization oa " - + "WHERE oa.user = :user " - + "OR oa.profile IN (:profiles) "; + + "WHERE oa.user = :user "; + if (!user.getProfiles().isEmpty()) { + strQuery += "OR oa.profile IN (:profiles) "; + } Query query = getSession().createQuery(strQuery); query.setParameter("user", user); - query.setParameterList("profiles", user.getProfiles()); + if (!user.getProfiles().isEmpty()) { + query.setParameterList("profiles", user.getProfiles()); + } return query.list(); }