@Test
public void shouldBeAbleToQueryWithLimitAndOffsetOnNonJoin() throws RepositoryException {

    // Try with the OFFSET expression ...
    String sql = "SELECT [jcr:path] FROM [car:Car] ORDER BY [jcr:path]";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    QueryResult result = query.execute();
    final String[] allCarPaths = {"/Cars/Hybrid/Nissan Altima", "/Cars/Hybrid/Toyota Highlander",
        "/Cars/Hybrid/Toyota Prius", "/Cars/Luxury/Bentley Continental", "/Cars/Luxury/Cadillac DTS",
        "/Cars/Luxury/Lexus IS350", "/Cars/Sports/Aston Martin DB9", "/Cars/Sports/Infiniti G37", "/Cars/Utility/Ford F-150",
        "/Cars/Utility/Hummer H3", "/Cars/Utility/Land Rover LR2", "/Cars/Utility/Land Rover LR3",
        "/Cars/Utility/Toyota Land Cruiser"};
    validateQuery().rowCount(13).hasColumns("jcr:path").hasNodesAtPaths(allCarPaths).validate(query, result);
    // Try with the OFFSET expression ...
    sql = "SELECT [jcr:path] FROM [car:Car] ORDER BY [jcr:path] LIMIT 2 OFFSET 2";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    result = query.execute();
    validateQuery().rowCount(2).hasColumns("jcr:path").hasNodesAtPaths(allCarPaths[2], allCarPaths[3])
                   .validate(query, result);
    // Try with the method ...
    sql = "SELECT [jcr:path] FROM [car:Car]";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    query.setOffset(2);
    result = query.execute();
    validateQuery().rowCount(11).hasColumns("jcr:path").validate(query, result);
}