diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationDataProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationDataProvider.java
index ab001db8cae6dd2a18aac6993ddc82133554086c..6509e9e03521032141898cd3639ed4a65f856b07 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationDataProvider.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationDataProvider.java
@@ -9,6 +9,10 @@ import java.util.Set;
 
 import org.hibernate.Query;
 import org.hibernate.Session;
+import org.hibernate.engine.spi.QueryParameters;
+import org.hibernate.engine.spi.TypedValue;
+import org.hibernate.query.internal.NativeQueryImpl;
+import org.hibernate.query.internal.QueryParameterBindingsImpl;
 
 import ch.systemsx.cisd.common.action.IMapper;
 import ch.systemsx.cisd.openbis.generic.server.batch.BatchOperationExecutor;
@@ -306,8 +310,6 @@ final public class AuthorizationDataProvider implements IAuthorizationDataProvid
             IMapper<List<V>, List<?>> valuesMapperOrNull, IMapper<List<R>, List<R>> resultMapperOrNull)
     {
         Session session = daoFactory.getSessionFactory().getCurrentSession();
-        final Query query = session.getNamedQuery(queryName);
-        query.setReadOnly(true);
 
         final Set<R> fullResults = new HashSet<R>();
 
@@ -324,6 +326,8 @@ final public class AuthorizationDataProvider implements IAuthorizationDataProvid
                 {
                     List<?> mappedValues = valuesMapperOrNull != null ? valuesMapperOrNull.map(entities) : entities;
                     assertNoNullElements(mappedValues);
+                    Query query = session.getNamedQuery(queryName);
+                    query.setReadOnly(true);
                     query.setParameterList(parameterName, mappedValues);
 
                     List<R> singleResults = cast(query.list());
diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java
index 4eca9d0cb88855bc7c10e72ba186ed3794bbf655..2af16863e54d9e1b42169c90705d51cc5a3b7725 100644
--- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java
+++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetSampleTest.java
@@ -77,6 +77,32 @@ import junit.framework.Assert;
  */
 public class GetSampleTest extends AbstractSampleTest
 {
+    @Test
+    public void testGetMoreThanThousandSamples()
+    {
+        // Given
+        String sessionToken = v3api.login(TEST_USER, PASSWORD);
+        List<SampleCreation> newSamples = new ArrayList<>();
+        for (int i = 0; i < 1024; i++) // size should be larger than BatchOperationExecutor.DEFAULT_BATCH_SIZE
+        {
+            SampleCreation creation = new SampleCreation();
+            creation.setCode("TEST_SAMPLE_" + (i + 1));
+            creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+            creation.setSpaceId(new SpacePermId("TEST-SPACE"));
+            newSamples.add(creation);
+        }
+        List<SamplePermId> sampleIds = v3api.createSamples(sessionToken, newSamples);
+        SampleFetchOptions fetchOptions = new SampleFetchOptions();
+        fetchOptions.withType();
+        fetchOptions.withSpace();
+
+        // When
+        Map<ISampleId, Sample> samples = v3api.getSamples(sessionToken, sampleIds, fetchOptions);
+
+        // Then
+        assertEquals(samples.size(), newSamples.size());
+    }
+
 
     @Test
     public void testGetByPermId()