dev.soffa.foundation.data.DataStore Maven / Gradle / Ivy
package dev.soffa.foundation.data;
import dev.soffa.foundation.model.PagedList;
import dev.soffa.foundation.model.Paging;
import dev.soffa.foundation.model.TenantId;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
public interface DataStore {
default Optional findById(Class entityClass, Object value) {
return findById(TenantId.CONTEXT, entityClass, value);
}
boolean ping();
Optional findById(TenantId tenant, Class entityClass, Object value);
default long count(Class entityClass) {
return count(TenantId.CONTEXT, entityClass);
}
long count(TenantId tenant, Class entityClass);
default long count(@NonNull Class entityClass, @NonNull Criteria criteria) {
return count(TenantId.CONTEXT, entityClass, criteria);
}
long count(TenantId tenant, @NonNull Class entityClass, @NonNull Criteria criteria);
default int delete(@NonNull Class entityClass, @NonNull Criteria criteria) {
return delete(TenantId.CONTEXT, entityClass, criteria);
}
int delete(TenantId tenant, @NonNull Class entityClass, @NonNull Criteria criteria);
default E insert(E entity) {
return insert(TenantId.CONTEXT, entity);
}
default int[] batch(List entity) {
return batch(TenantId.CONTEXT, entity);
}
int[] batch(TenantId tenant, List entity);
default int[] batch(String table, List entity) {
return batch(TenantId.CONTEXT, table, entity);
}
int[] batch(TenantId tenantId, String table, List entity);
E insert(TenantId tenant, E entity);
default E update(E entity) {
return update(TenantId.CONTEXT, entity);
}
E update(TenantId tenant, E entity);
default int delete(E entity) {
return delete(TenantId.CONTEXT, entity);
}
int delete(TenantId tenant, E entity);
default PagedList find(Class entityClass, Criteria criteria) {
return find(TenantId.CONTEXT, entityClass, criteria, Paging.DEFAULT);
}
PagedList find(TenantId tenant, Class entityClass, Criteria criteria, Paging paging);
default PagedList find(Class entityClass, Criteria criteria, Paging paging) {
return find(TenantId.CONTEXT, entityClass, criteria, paging);
}
default int execute(String command) {
return execute(TenantId.CONTEXT, command);
}
int execute(TenantId tenant, String command);
default PagedList find(TenantId tenant, Class entityClass, Criteria criteria) {
return find(tenant, entityClass, criteria, Paging.DEFAULT);
}
default Optional get(Class entityClass, Criteria criteria) {
return get(TenantId.CONTEXT, entityClass, criteria);
}
Optional get(TenantId tenant, Class entityClass, Criteria criteria);
default PagedList findAll(Class entityClass) {
return findAll(TenantId.CONTEXT, entityClass);
}
default PagedList findAll(TenantId tenant, Class entityClass) {
return findAll(tenant, entityClass, Paging.DEFAULT);
}
PagedList findAll(TenantId tenant, Class entityClass, Paging paging);
List query(String query, Class resultClass);
void useTransaction(TenantId tenant, Consumer consumer);
double sumBy(TenantId tenant, Class entityClass, String field, Criteria criteria);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy