org.babyfish.jimmer.sql.Entities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql;
import org.babyfish.jimmer.Input;
import org.babyfish.jimmer.View;
import org.babyfish.jimmer.lang.NewChain;
import org.babyfish.jimmer.meta.TypedProp;
import org.babyfish.jimmer.sql.ast.mutation.*;
import org.babyfish.jimmer.sql.ast.query.Example;
import org.babyfish.jimmer.sql.fetcher.Fetcher;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* To be absolutely cache friendly,
* all query methods like "find...ById(s)" of this class ignore the global filters.
*
* The mentions here ignore global filters, only for aggregate root objects,
* excluding deeper objects fetched by object fetcher.
*/
public interface Entities {
@NewChain
Entities forUpdate();
@NewChain
Entities forConnection(Connection con);
@Nullable
E findById(Class type, Object id);
@NotNull
List findByIds(Class type, Collection> ids);
@NotNull
Map findMapByIds(Class type, Collection ids);
@Nullable
E findById(Fetcher fetcher, Object id);
@NotNull
List findByIds(Fetcher fetcher, Collection> ids);
@NotNull
Map findMapByIds(Fetcher fetcher, Collection ids);
List findAll(Class type);
List findAll(Class type, TypedProp.Scalar, ?> ... sortedProps);
List findAll(Fetcher fetcher, TypedProp.Scalar, ?> ... sortedProps);
List findByExample(Example example, TypedProp.Scalar, ?> ... sortedProps);
List findByExample(Example example, Fetcher fetcher, TypedProp.Scalar, ?> ... sortedProps);
> List findExample(Class viewType, Example example, TypedProp.Scalar, ?> ... sortedProps);
default SimpleSaveResult save(E entity) {
return saveCommand(entity).execute();
}
SimpleEntitySaveCommand saveCommand(E entity);
default BatchSaveResult saveEntities(Collection entities) {
return saveEntitiesCommand(entities).execute();
}
/**
* This method will be deleted in 1.0,
* please use {@link #saveEntities(Collection)}
*/
default BatchSaveResult batchSave(Collection entities) {
return saveEntities(entities);
}
/**
* This method will be deleted in 1.0,
* please use {@link #saveEntities(Collection)}
*/
default BatchSaveResult saveAll(Collection entities) {
return saveEntities(entities);
}
default SimpleSaveResult save(Input input) {
return save(input.toEntity());
}
default SimpleEntitySaveCommand saveCommand(Input input) {
return saveCommand(input.toEntity());
}
BatchEntitySaveCommand saveEntitiesCommand(Collection entities);
default BatchEntitySaveCommand saveInputsCommand(Collection> inputs) {
List entities = new ArrayList<>(inputs.size());
for (Input input : inputs) {
entities.add(input.toEntity());
}
return saveEntitiesCommand(entities);
}
/**
* This method will be deleted in 1.0,
* please use {@link #saveEntitiesCommand(Collection)}
*/
@Deprecated
default BatchEntitySaveCommand batchSaveCommand(Collection entities) {
return saveEntitiesCommand(entities);
}
/**
* This method will be deleted in 1.0,
* please use {@link #saveEntitiesCommand(Collection)}
*/
@Deprecated
default BatchEntitySaveCommand saveAllCommand(Collection entities) {
return saveEntitiesCommand(entities);
}
default DeleteResult delete(Class> type, Object id) {
return deleteCommand(type, id).execute();
}
default DeleteResult delete(Class> type, Object id, DeleteMode mode) {
return deleteCommand(type, id).setMode(mode).execute();
}
DeleteCommand deleteCommand(Class> type, Object id);
default DeleteCommand deleteCommand(Class> type, Object id, DeleteMode mode) {
return deleteCommand(type, id).setMode(mode);
}
default DeleteResult deleteAll(Class> type, Collection> ids) {
return deleteAllCommand(type, ids).execute();
}
default DeleteResult deleteAll(Class> type, Collection> ids, DeleteMode mode) {
return deleteAllCommand(type, ids).setMode(mode).execute();
}
/**
* This method will be deleted in 1.0,
* please use {@link #saveEntitiesCommand(Collection)}
*/
@Deprecated
default DeleteResult batchDelete(Class> type, Collection> ids) {
return batchDeleteCommand(type, ids).execute();
}
/**
* This method will be deleted in 1.0,
* please use {@link #deleteAll(Class, Collection, DeleteMode)}
*/
@Deprecated
default DeleteResult batchDelete(Class> type, Collection> ids, DeleteMode mode) {
return batchDeleteCommand(type, ids).setMode(mode).execute();
}
DeleteCommand deleteAllCommand(Class> type, Collection> ids);
/**
* This method will be deleted in 1.0,
* please use {@link #deleteAllCommand(Class, Collection)}
*/
@Deprecated
default DeleteCommand batchDeleteCommand(Class> type, Collection> ids) {
return deleteAllCommand(type, ids);
}
}