com.jpattern.orm.query.OrmFindQuery Maven / Gradle / Ivy
package com.jpattern.orm.query;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.jpattern.orm.classtool.IOrmClassTool;
import com.jpattern.orm.classtool.IOrmClassToolMap;
import com.jpattern.orm.exception.OrmException;
import com.jpattern.orm.exception.OrmNotUniqueResultException;
import com.jpattern.orm.query.clause.From;
import com.jpattern.orm.query.clause.OrderBy;
import com.jpattern.orm.query.clause.OrmFrom;
import com.jpattern.orm.query.clause.OrmOrderBy;
import com.jpattern.orm.query.clause.OrmWhere;
import com.jpattern.orm.query.clause.Where;
import com.jpattern.orm.session.ResultSetReader;
import com.jpattern.orm.session.SessionSqlPerformer;
import com.jpattern.orm.session.SqlPerformer;
import com.jpattern.orm.util.GenericWrapper;
/**
*
* @author Francesco Cina
*
* 20/giu/2011
*/
public class OrmFindQuery extends AQuery implements FindQuery, INameSolverConsumer {
private INameSolver nameSolver = new NullNameSolver();
private final IOrmClassToolMap ormClassToolMap;
private final Class clazz;
private boolean distinct;
private final SessionSqlPerformer session;
private int queryTimeout = 0;
private int maxRows = 0;
private LockMode lockMode = LockMode.NO_LOCK;
private final Where> whereExpression = new OrmWhere>(this);
private final OrmOrderBy> orderBy = new OrmOrderBy>(this);
private final From> from;
public OrmFindQuery(IOrmClassToolMap ormClassToolMap, SessionSqlPerformer session, Class clazz) {
this.ormClassToolMap = ormClassToolMap;
this.session = session;
this.clazz = clazz;
from = new OrmFrom>(ormClassToolMap, this);
}
@Override
public final From> from() throws OrmException {
return from;
}
@Override
public final Where> where() throws OrmException {
return whereExpression;
}
@Override
public final OrderBy> orderBy() throws OrmException {
return orderBy;
}
@Override
public final int getMaxRows() throws OrmException {
return this.maxRows;
}
@Override
public final FindQuery setQueryTimeout(int queryTimeout) {
this.queryTimeout = queryTimeout;
return this;
}
@Override
public final int getQueryTimeout() {
return this.queryTimeout;
}
@Override
public final FindQuery setMaxRows(int maxRows) throws OrmException {
this.maxRows = maxRows;
return this;
}
@Override
public void setNameSolver(INameSolver nameSolver) {
this.nameSolver = nameSolver;
where().setNameSolver(nameSolver);
orderBy().setNameSolver(nameSolver);
from().setNameSolver(nameSolver);
}
@Override
public List findList() {
final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy