org.liveSense.api.sql.SimpleBeanSQLQueryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.liveSense.service.dataSourceProvider Show documentation
Show all versions of org.liveSense.service.dataSourceProvider Show documentation
Simple DBCP pooled datasource provider.
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;
}
}