mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#1262 - ENH: Support firstRow maxRows with findNative()
This commit is contained in:
1 parent
6c1b295d41
commit
9926cad7f1
3 files changed
+56
-26
No files matched your search
@@ -366,6 +366,10 @@ class CQueryBuilder {
|
||||
return new SqlTreeBuilder(this, request, predicates).build();
|
||||
}
|
||||
|
||||
private String nativeQueryPaging(SpiQuery<?> query, String sql) {
|
||||
return dbPlatform.getBasicSqlLimiter().limit(sql, query.getFirstRow(), query.getMaxRows());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SqlTree by reading the ResultSetMetaData and mapping table/columns to bean property paths.
|
||||
*/
|
||||
@@ -375,6 +379,9 @@ class CQueryBuilder {
|
||||
|
||||
// parse named parameters returning the final sql to execute
|
||||
String sql = predicates.parseBindParams(query.getNativeSql());
|
||||
if (query.hasMaxRowsOrFirstRow()) {
|
||||
sql = nativeQueryPaging(query, sql);
|
||||
}
|
||||
query.setGeneratedSql(sql);
|
||||
|
||||
Connection connection = request.getTransaction().getConnection();
|
||||
|
||||
@@ -996,7 +996,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
CQueryPlanKey createQueryPlanKey() {
|
||||
|
||||
if (isNativeSql()) {
|
||||
queryPlanKey = new NativeSqlQueryPlanKey(nativeSql);
|
||||
queryPlanKey = new NativeSqlQueryPlanKey(nativeSql + "-" + firstRow + "-" + maxRows);
|
||||
} else {
|
||||
queryPlanKey = new OrmQueryPlanKey(beanDescriptor.getDiscValue(), m2mIncludeJoin, type, detail, maxRows, firstRow,
|
||||
disableLazyLoading, orderBy,
|
||||
|
||||
Reference in new issue
Block a user