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

org.liveSense.api.sql.SimpleBeanSQLQueryBuilder Maven / Gradle / Ivy

The newest version!
package org.liveSense.api.sql;

import java.util.List;

import org.liveSense.api.sql.exceptions.SQLException;
import org.liveSense.misc.queryBuilder.QueryBuilder;
import org.liveSense.misc.queryBuilder.domains.LimitClause;
import org.liveSense.misc.queryBuilder.domains.Operator;
import org.liveSense.misc.queryBuilder.domains.OrderByClause;


public class SimpleBeanSQLQueryBuilder  extends QueryBuilder {

	String statement;
	
	public SimpleBeanSQLQueryBuilder(Class clazz) throws SQLException {
		this(clazz, null, null, null);
	}

	public SimpleBeanSQLQueryBuilder(Class clazz, Operator parameters) throws SQLException {
		this(clazz, parameters, null, null);
	}

	public SimpleBeanSQLQueryBuilder(Class clazz, LimitClause limit) throws SQLException {
		this(clazz, null, limit, null);
	}

	public SimpleBeanSQLQueryBuilder(Class clazz, Operator parameters, LimitClause limit) throws SQLException {
		this(clazz, parameters, limit, null);
	}
		
	public SimpleBeanSQLQueryBuilder(Class clazz, Operator parameters, LimitClause limit, List orderBy) throws SQLException {
		// Search for entity annotation
		this.setClazz(clazz);
		String tableName = AnnotationHelper.getTableName(clazz);
		if (tableName == null || "".equals(tableName)) throw new SQLException("Entity annotation does not found");
		this.statement = "SELECT * FROM "+tableName;
				
		setLimit(limit);
		setOrderBy(orderBy);
		setWhere(parameters);
	}

	@Override
	public String getQuery() {
		return this.statement;
	}
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy