io.github.holmofy.data.jdbc.EnhancedJdbcRepository Maven / Gradle / Ivy
The newest version!
package io.github.holmofy.data.jdbc;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jdbc.core.JdbcAggregateOperations;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.relational.core.query.CriteriaDefinition;
import org.springframework.data.relational.core.query.Query;
import java.util.Optional;
public class EnhancedJdbcRepository extends SimpleJdbcRepository implements CriteriaExecutor {
private final JdbcAggregateOperations entityOperations;
private final PersistentEntity entity;
public EnhancedJdbcRepository(JdbcAggregateOperations entityOperations,
PersistentEntity entity,
JdbcConverter converter) {
super(entityOperations, entity, converter);
this.entityOperations = entityOperations;
this.entity = entity;
}
@Override
public Optional findOne(CriteriaDefinition criteria) {
return entityOperations.findOne(Query.query(criteria), entity.getType());
}
@Override
public Iterable findAll(CriteriaDefinition criteria) {
return entityOperations.findAll(Query.query(criteria), entity.getType());
}
@Override
public Page findAll(CriteriaDefinition criteria, Pageable pageable) {
return entityOperations.findAll(Query.query(criteria), entity.getType(), pageable);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy