Interface Template


public interface Template
A template interface for generic data manipulation operations.
  • Method Summary

    Modifier and Type
    Method
    Description
    <K, T> boolean
    delete(Class<T> type, K id)
    Deletes an entity by its identifier and type from the data store.
    <K> boolean
    delete(String table, K id)
    Deletes an entity by its identifier from the data store.
    <K, T> boolean
    deleteAllById(Class<T> type, Iterable<K> ids)
    Deletes multiple entities by their identifiers and type from the data store.
    <K> boolean
    deleteAllById(String table, Iterable<K> ids)
    Deletes multiple entities by their identifiers and table from the data store.
    <K, T> List<T>
    findAllById(Class<T> type, Iterable<K> ids)
    Finds multiple entities by their identifiers and type in the data store.
    <K, T> Optional<T>
    findById(Class<T> type, K id)
    Finds an entity by its identifier and type in the data store.
    <T> boolean
    insert(Iterable<T> entities)
    Inserts multiple entities into the data store.
    <T> boolean
    insert(T entity)
    Inserts a single entity into the data store.
    <T> boolean
    update(Iterable<T> entities)
    Updates multiple entities in the data store.
    <T> boolean
    update(T entity)
    Updates a single entity in the data store.
    <T> boolean
    upsert(Iterable<T> entities)
    Upserts (inserts or updates) multiple entities into the data store.
    <T> boolean
    upsert(T entity)
    Upserts (inserts or updates) a single entity into the data store.
  • Method Details

    • insert

      <T> boolean insert(T entity)
      Inserts a single entity into the data store.
      Type Parameters:
      T - The type of the entity.
      Parameters:
      entity - The entity to be inserted.
      Returns:
      true if the insertion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entity is null.
    • insert

      <T> boolean insert(Iterable<T> entities)
      Inserts multiple entities into the data store.
      Type Parameters:
      T - The type of the entities.
      Parameters:
      entities - The entities to be inserted.
      Returns:
      true if the insertion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entities is null.
    • update

      <T> boolean update(T entity)
      Updates a single entity in the data store.
      Type Parameters:
      T - The type of the entity.
      Parameters:
      entity - The entity to be updated.
      Returns:
      true if the update is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entity is null.
    • update

      <T> boolean update(Iterable<T> entities)
      Updates multiple entities in the data store.
      Type Parameters:
      T - The type of the entities.
      Parameters:
      entities - The entities to be updated.
      Returns:
      true if the update is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entities is null.
    • upsert

      <T> boolean upsert(T entity)
      Upserts (inserts or updates) a single entity into the data store.
      Type Parameters:
      T - The type of the entity.
      Parameters:
      entity - The entity to be upserted.
      Returns:
      true if the upsert is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entity is null.
    • upsert

      <T> boolean upsert(Iterable<T> entities)
      Upserts (inserts or updates) multiple entities into the data store.
      Type Parameters:
      T - The type of the entities.
      Parameters:
      entities - The entities to be upserted.
      Returns:
      true if the upsert is successful; false otherwise.
      Throws:
      NullPointerException - if the provided entities is null.
    • delete

      <K> boolean delete(String table, K id)
      Deletes an entity by its identifier from the data store.
      Type Parameters:
      K - The type of the identifier.
      Parameters:
      table - The table or entity type associated with the data. If provided as a Class or instance, it takes the simple name of the class in lowercase.
      id - The identifier of the entity to be deleted.
      Returns:
      true if the deletion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided table or id is null.
    • delete

      <K, T> boolean delete(Class<T> type, K id)
      Deletes an entity by its identifier and type from the data store.
      Type Parameters:
      K - The type of the identifier.
      T - The type of the entity.
      Parameters:
      type - The class representing the entity type. It takes the simple name of the class in lowercase.
      id - The identifier of the entity to be deleted.
      Returns:
      true if the deletion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided type or id is null.
    • deleteAllById

      <K, T> boolean deleteAllById(Class<T> type, Iterable<K> ids)
      Deletes multiple entities by their identifiers and type from the data store.
      Type Parameters:
      K - The type of the identifier.
      T - The type of the entity.
      Parameters:
      type - The class representing the entity type. It takes the simple name of the class in lowercase.
      ids - The identifiers of the entities to be deleted.
      Returns:
      true if the deletion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided type or ids is null.
    • deleteAllById

      <K> boolean deleteAllById(String table, Iterable<K> ids)
      Deletes multiple entities by their identifiers and table from the data store.
      Type Parameters:
      K - The type of the identifier.
      Parameters:
      table - The table or entity type associated with the data. If provided as a Class or instance, it takes the simple name of the class in lowercase.
      ids - The identifiers of the entities to be deleted.
      Returns:
      true if the deletion is successful; false otherwise.
      Throws:
      NullPointerException - if the provided table or ids is null.
    • findById

      <K, T> Optional<T> findById(Class<T> type, K id)
      Finds an entity by its identifier and type in the data store.
      Type Parameters:
      K - The type of the identifier.
      T - The type of the entity.
      Parameters:
      type - The class representing the entity type. It takes the simple name of the class in lowercase.
      id - The identifier of the entity to be retrieved.
      Returns:
      an Optional containing the entity if found, or an empty Optional otherwise.
      Throws:
      NullPointerException - if the provided id or type is null.
    • findAllById

      <K, T> List<T> findAllById(Class<T> type, Iterable<K> ids)
      Finds multiple entities by their identifiers and type in the data store.
      Type Parameters:
      K - The type of the identifier.
      T - The type of the entity.
      Parameters:
      type - The class representing the entity type. It takes the simple name of the class in lowercase.
      ids - The identifiers of the entities to be retrieved.
      Returns:
      a List containing the retrieved entities.
      Throws:
      NullPointerException - if the provided ids or type is null.