@Test public void populateParameters() { org.hibernate.query.Query hquery = mock(org.hibernate.query.Query.class); Query query = mock(Query.class); int offset = 13; when(query.getOffset()).thenReturn(offset); int limit = 7; when(query.getLimit()).thenReturn(limit); Map<String, Object> namedParameters = new HashMap<String, Object>(); namedParameters.put("alice", 10); List<String> listValue = Collections.singletonList("yellow"); namedParameters.put("bob", listValue); when(query.getNamedParameters()).thenReturn(namedParameters); this.executor.populateParameters(hquery, query); verify(hquery).setFirstResult(offset); verify(hquery).setMaxResults(limit); verify(hquery).setParameter("alice", 10); verify(hquery).setParameterList("bob", listValue); }
protected void populateParameters(org.hibernate.query.Query<?> hquery, Query query) { if (query.getOffset() > 0) { hquery.setFirstResult(query.getOffset()); } if (query.getLimit() > 0) { hquery.setMaxResults(query.getLimit()); } for (Entry<String, Object> e : query.getNamedParameters().entrySet()) { setNamedParameter(hquery, e.getKey(), e.getValue()); } Map<Integer, Object> positionalParameters = query.getPositionalParameters(); if (positionalParameters.size() > 0) { positionalParameters.forEach(hquery::setParameter); } }
HqlQueryExecutor implements QueryExecutor, Initializable { protected void populateParameters(org.hibernate.query.Query<?> hquery, Query query) { if (query.getOffset() > 0) { hquery.setFirstResult(query.getOffset()); } if (query.getLimit() > 0) { hquery.setMaxResults(query.getLimit()); } for (Entry<String, Object> e : query.getNamedParameters().entrySet()) { setNamedParameter(hquery, e.getKey(), e.getValue()); } Map<Integer, Object> positionalParameters = query.getPositionalParameters(); if (positionalParameters.size() > 0) { positionalParameters.forEach(hquery::setParameter); } } }
HqlQueryExecutor implements QueryExecutor, Initializable { protected void populateParameters(org.hibernate.query.Query<?> hquery, Query query) { if (query.getOffset() > 0) { hquery.setFirstResult(query.getOffset()); } if (query.getLimit() > 0) { hquery.setMaxResults(query.getLimit()); } for (Entry<String, Object> e : query.getNamedParameters().entrySet()) { setNamedParameter(hquery, e.getKey(), e.getValue()); } Map<Integer, Object> positionalParameters = query.getPositionalParameters(); if (positionalParameters.size() > 0) { positionalParameters.forEach(hquery::setParameter); } }  }
HqlQueryExecutor implements QueryExecutor, Initializable { protected void populateParameters(org.hibernate.query.Query<?> hquery, Query query) { if (query.getOffset() > 0) { hquery.setFirstResult(query.getOffset()); } if (query.getLimit() > 0) { hquery.setMaxResults(query.getLimit()); } for (Entry<String, Object> e : query.getNamedParameters().entrySet()) { setNamedParameter(hquery, e.getKey(), e.getValue()); } Map<Integer, Object> positionalParameters = query.getPositionalParameters(); if (positionalParameters.size() > 0) { positionalParameters.forEach(hquery::setParameter); } }  @Override void initialize(); @Override List<T> execute(final Query query); }
HqlQueryExecutor implements QueryExecutor, Initializable { protected void populateParameters(org.hibernate.query.Query<?> hquery, Query query) { if (query.getOffset() > 0) { hquery.setFirstResult(query.getOffset()); } if (query.getLimit() > 0) { hquery.setMaxResults(query.getLimit()); } for (Entry<String, Object> e : query.getNamedParameters().entrySet()) { setNamedParameter(hquery, e.getKey(), e.getValue()); } Map<Integer, Object> positionalParameters = query.getPositionalParameters(); if (positionalParameters.size() > 0) { positionalParameters.forEach(hquery::setParameter); } }  @Override void initialize(); @Override List<T> execute(final Query query);  }