
win.doyto.query.service.CommonCrudService Maven / Gradle / Ivy
package win.doyto.query.service;
import win.doyto.query.entity.Persistable;
/**
* CommonCrudService
*
* @author f0rb on 2019-06-01
*/
interface CommonCrudService extends QueryService {
void create(E e);
int update(E e);
default E save(E e) {
if (isNewEntity(e)) {
create(e);
} else {
update(e);
}
return e;
}
default boolean isNewEntity(E e) {
return e.isNew();
}
int patch(E e);
/**
* 执行INSERT INTO [TABLE] (col1, col2) VALUES (?), (?)
*
* - 会清空全部缓存
* - 不会按id清理缓存
* - 不会执行{@link win.doyto.query.entity.EntityAspect#afterCreate(Object)}
*
*
* @param entities entities to insert
* @param columns update columns on duplicate
* @return amount of updated entities
*/
int batchInsert(Iterable entities, String... columns);
/**
* 执行UPDATE [TABLE] SET ... WHERE ...
*
* - 会清空全部缓存
* - 不会按id清理缓存
* - 不会执行{@link win.doyto.query.entity.EntityAspect#afterUpdate(Object, Object)}
*
*
* @param e entity object
* @param q query object
* @return amount of updated entities
*/
int patch(E e, Q q);
/**
* 执行DELETE FORM [TABLE] WHERE ...
*
* - 会清空全部缓存
* - 不会按id清理缓存
* - 不会执行{@link win.doyto.query.entity.EntityAspect#afterDelete(Object)}
*
*
* @param q query object
* @return amount of updated entities
*/
int delete(Q q);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy