All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.dialect.pagination.SQL2008StandardLimitHandler Maven / Gradle / Ivy

There is a newer version: 6.5.0.CR2
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.dialect.pagination;

import org.hibernate.engine.spi.RowSelection;

/**
 * LIMIT clause handler compatible with ISO and ANSI SQL:2008 standard.
 * 
 * @author zhouyanming ([email protected])
 */
public class SQL2008StandardLimitHandler extends AbstractLimitHandler {

	public static final SQL2008StandardLimitHandler INSTANCE = new SQL2008StandardLimitHandler();

	/**
	 * Constructs a SQL2008StandardLimitHandler
	 */
	private SQL2008StandardLimitHandler() {
		// NOP
	}

	@Override
	public boolean supportsLimit() {
		return true;
	}

	@Override
	public String processSql(String sql, RowSelection selection) {
		if (LimitHelper.useLimit( this, selection )) {
			return sql + (LimitHelper.hasFirstRow( selection ) ?
					" offset ? rows fetch next ? rows only" : " fetch first ? rows only");
		}
		else {
			// or return unaltered SQL
			return sql;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy