
win.doyto.query.core.JoinQueryExecutor Maven / Gradle / Ivy
// Generated by delombok at Sat Aug 10 11:56:00 CST 2019
package win.doyto.query.core;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcOperations;
import win.doyto.query.service.PageList;
import java.util.List;
/**
* JoinQueryExecutor
*
* @author f0rb on 2019-06-09
*/
public class JoinQueryExecutor {
@Autowired
private JdbcOperations jdbcOperations;
private final JoinQueryBuilder joinQueryBuilder;
private BeanPropertyRowMapper beanPropertyRowMapper;
public JoinQueryExecutor(Class entityClass) {
this.joinQueryBuilder = new JoinQueryBuilder(entityClass);
this.beanPropertyRowMapper = new BeanPropertyRowMapper<>(entityClass);
}
public JoinQueryExecutor(JdbcOperations jdbcOperations, Class entityClass) {
this(entityClass);
this.jdbcOperations = jdbcOperations;
}
public PageList page(Q q) {
return new PageList<>(query(q), count(q));
}
public List query(Q q) {
SqlAndArgs sqlAndArgs = buildJoinSelectAndArgs(q);
return jdbcOperations.query(sqlAndArgs.getSql(), beanPropertyRowMapper, sqlAndArgs.getArgs());
}
public Long count(Q q) {
SqlAndArgs sqlAndArgs = joinQueryBuilder.buildJoinCountAndArgs(q);
return jdbcOperations.queryForObject(sqlAndArgs.getSql(), sqlAndArgs.getArgs(), Long.class);
}
public SqlAndArgs buildJoinSelectAndArgs(Q q) {
return joinQueryBuilder.buildJoinSelectAndArgs(q);
}
@java.lang.SuppressWarnings("all")
@lombok.Generated
public JoinQueryExecutor(final JdbcOperations jdbcOperations, final JoinQueryBuilder joinQueryBuilder, final BeanPropertyRowMapper beanPropertyRowMapper) {
this.jdbcOperations = jdbcOperations;
this.joinQueryBuilder = joinQueryBuilder;
this.beanPropertyRowMapper = beanPropertyRowMapper;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy