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

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

There is a newer version: 7.0.0.Alpha1
Show newest version
package org.hibernate.dialect.pagination;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.hibernate.engine.spi.RowSelection;

/**
 * Handler not supporting query LIMIT clause. JDBC API is used to set maximum number of returned rows.
 *
 * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
 */
public class NoopLimitHandler extends AbstractLimitHandler {
	public NoopLimitHandler(String sql, RowSelection selection) {
		super( sql, selection );
	}

	public String getProcessedSql() {
		return sql;
	}

	public int bindLimitParametersAtStartOfQuery(PreparedStatement statement, int index) {
		return 0;
	}

	public int bindLimitParametersAtEndOfQuery(PreparedStatement statement, int index) {
		return 0;
	}

	public void setMaxRows(PreparedStatement statement) throws SQLException {
		if ( LimitHelper.hasMaxRows( selection ) ) {
			statement.setMaxRows( selection.getMaxRows() + convertToFirstRowValue( LimitHelper.getFirstRow( selection ) ) );
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy