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