Java 类org.hibernate.dialect.pagination.AbstractLimitHandler 实例源码

项目:phoenix-hibernate-dialect    文件:PhoenixDialect.java   
@Override
public LimitHandler getLimitHandler() {
    return new AbstractLimitHandler() {
        @Override
        public boolean supportsLimit() {
            return true;
        }

        @Override
        public String processSql(String sql, RowSelection selection) {
            if (LimitHelper.useLimit(this, selection)) {
                final boolean hasMaxRows = LimitHelper.hasMaxRows(selection);
                final boolean hasOffset = LimitHelper.hasFirstRow(selection);
                return sql + (hasMaxRows ? " limit ?" : "")
                            + (hasOffset ? " offset ?" : "");
            }
            return sql;
        }
    };
}