Integer limit = null;
Integer start = null;
Integer maxSize = null;
boolean isMaxResultsLimitBlocking = false;
IDataStore dataStore = null;
IDataSet dataSet = null;
Integer resultNumber = null;
try {
statement.setParameters( engineInstance.getEnv() );
String jpaQueryStr = statement.getQueryString();
//String sqlQuery = statement.getSqlQueryString();
logger.debug("Executable query (HQL/JPQL): [" + jpaQueryStr+ "]");
//logger.debug("Executable query (SQL): [" + sqlQuery + "]");
UserProfile userProfile = (UserProfile)engineInstance.getEnv().get(EngineConstants.ENV_USER_PROFILE);
auditlogger.info("[" + userProfile.getUserId() + "]:: HQL/JPQL: " + jpaQueryStr);
//auditlogger.info("[" + userProfile.getUserId() + "]:: SQL: " + sqlQuery);
logger.debug("Executing query ...");
dataSet = QbeDatasetFactory.createDataSet(statement);
dataSet.setAbortOnOverflow(isMaxResultsLimitBlocking);
Map userAttributes = new HashMap();
UserProfile profile = (UserProfile)engineInstance.getEnv().get(EngineConstants.ENV_USER_PROFILE);
Iterator it = profile.getUserAttributeNames().iterator();
while(it.hasNext()) {
String attributeName = (String)it.next();
Object attributeValue = profile.getUserAttribute(attributeName);
userAttributes.put(attributeName, attributeValue);
}
dataSet.addBinding("attributes", userAttributes);
dataSet.addBinding("parameters", engineInstance.getEnv());
dataSet.loadData(start, limit, (maxSize == null? -1: maxSize.intValue()));
dataStore = dataSet.getDataStore();
Assert.assertNotNull(dataStore, "The dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
logger.debug("Query executed succesfully");
resultNumber = (Integer)dataStore.getMetaData().getProperty("resultNumber");
Assert.assertNotNull(resultNumber, "property [resultNumber] of the dataStore returned by loadData method of the class [" + dataSet.getClass().getName()+ "] cannot be null");
logger.debug("Total records: " + resultNumber);
boolean overflow = maxSize != null && resultNumber >= maxSize;
if (overflow) {