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

dk.eobjects.metamodel.dialects.MysqlQueryRewriter Maven / Gradle / Ivy

The newest version!
/**
 *  This file is part of MetaModel.
 *
 *  MetaModel is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  MetaModel is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with MetaModel.  If not, see .
 */
package dk.eobjects.metamodel.dialects;

import dk.eobjects.metamodel.JdbcDataContextStrategy;
import dk.eobjects.metamodel.query.Query;

public class MysqlQueryRewriter extends DefaultQueryRewriter implements
		IQueryRewriter {

	/**
	 * If the maxrows property of the query is set, then we will use MySQLs
	 * LIMIT function.
	 */
	@Override
	public String rewriteQuery(JdbcDataContextStrategy strategy, Query query) {
		String queryString = super.rewriteQuery(strategy, query);
		Integer maxRows = query.getMaxRows();
		if (maxRows != null && maxRows > 0) {
			queryString = queryString + " LIMIT " + maxRows;
		}
		return queryString;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy