Class SimpleRepositoryMethodSaveAllHandler

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryMethodSaveAllHandler
All Implemented Interfaces:
SimpleRepositoryMethodHandler

public class SimpleRepositoryMethodSaveAllHandler extends Object implements SimpleRepositoryMethodHandler
Implementation of SimpleRepositoryMethodHandler for handling the "saveAll" method. This handler saves a list of entities using the Bibernate session.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • METHOD_NAME

      private static final String METHOD_NAME
      The prefix for the handled method (saveAll).
      See Also:
    • DELETE_METHOD_SHOULD_HAVE_ONE_PARAMETER_ID

      private static final String DELETE_METHOD_SHOULD_HAVE_ONE_PARAMETER_ID
      See Also:
  • Constructor Details

    • SimpleRepositoryMethodSaveAllHandler

      public SimpleRepositoryMethodSaveAllHandler()
  • Method Details

    • isMethodHandle

      public boolean isMethodHandle(Method method)
      Checks if the given method can be handled by this handler. Checks if the method name is "saveAll".
      Specified by:
      isMethodHandle in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The method to check.
      Returns:
      true if this handler can handle the method, false otherwise.
    • execute

      public Object execute(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata)
      Executes the given repository method using the provided parameters, repository details, and method metadata. Executes the "saveAll" method by saving a list of entities using the Bibernate session.
      Specified by:
      execute in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The repository method to execute.
      parameters - The parameters for the method invocation.
      repositoryDetails - Details about the repository, including its name, primary key type, entity type, etc.
      methodMetadata - Metadata for the repository method, including its name, return type, and parameters.
      Returns:
      The result of the repository method execution.
    • executeHelper

      private <T> void executeHelper(Class<T> entityClass, Collection entities, BibernateSession bringSession)
      Helper method for executing the save operation on a BibernateSession instance. Saves a collection of entities of the specified class using the provided BibernateSession.
      Type Parameters:
      T - the type of the entities being saved
      Parameters:
      entityClass - the class of the entities to be saved
      entities - the collection of entities to be saved
      bringSession - the BibernateSession instance used for saving entities