@FixFor( "MODE-1468" )
@Test
public void shouldAllowCreationAndExecutionOfQueryObjectModelWithLimit() throws Exception {
QueryManager queryManager = session.getWorkspace().getQueryManager();
QueryObjectModelFactory qomFactory = queryManager.getQOMFactory();
Selector selector = qomFactory.selector("car:Car", "car");
PropertyValue propValue = qomFactory.propertyValue("car", "car:userRating");
Literal literal = qomFactory.literal(session.getValueFactory().createValue("4")); // use a String since it's LIKE
Constraint constraint = qomFactory.comparison(propValue, JCR_OPERATOR_LIKE, literal);
Column[] columns = new Column[4];
columns[0] = qomFactory.column("car", "car:maker", "maker");
columns[1] = qomFactory.column("car", "car:model", "car:model");
columns[2] = qomFactory.column("car", "car:year", "car:year");
columns[3] = qomFactory.column("car", "car:userRating", "car:userRating");
Ordering[] orderings = null;
Limit limit = qomFactory.limit(2, 0);
boolean isDistinct = false;
// Build and execute the query ...
SelectQuery selectQuery = qomFactory.select(selector, constraint, orderings, columns, limit, isDistinct);
Query query1 = qomFactory.createQuery(selectQuery);
QueryResult result1 = query1.execute();
String[] columnNames = {"maker", "car:model", "car:year", "car:userRating"};
validateQuery().rowCount(2).hasColumns(columnNames).validate(query1, result1);
// Now get the JCR-SQL2 statement from the QOM ...