All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 (?), (?)
     * 
    *
  1. 清空全部缓存
  2. *
  3. 不会按id清理缓存
  4. *
  5. 不会执行{@link win.doyto.query.entity.EntityAspect#afterCreate(Object)}
  6. *
* * @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 ... *
    *
  1. 清空全部缓存
  2. *
  3. 不会按id清理缓存
  4. *
  5. 不会执行{@link win.doyto.query.entity.EntityAspect#afterUpdate(Object, Object)}
  6. *
* * @param e entity object * @param q query object * @return amount of updated entities */ int patch(E e, Q q); /** * 执行DELETE FORM [TABLE] WHERE ... *
    *
  1. 清空全部缓存
  2. *
  3. 不会按id清理缓存
  4. *
  5. 不会执行{@link win.doyto.query.entity.EntityAspect#afterDelete(Object)}
  6. *
* * @param q query object * @return amount of updated entities */ int delete(Q q); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy