Class SimpleRepositoryMethodSaveHandler
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryMethodSaveHandler
- All Implemented Interfaces:
SimpleRepositoryMethodHandler
public class SimpleRepositoryMethodSaveHandler
extends Object
implements SimpleRepositoryMethodHandler
Implementation of
SimpleRepositoryMethodHandler for handling the "save" method.
This handler saves an entity using the Bibernate session.- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final StringThe prefix for the handled method (save).Fields inherited from interface io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryMethodHandler
CANNOT_FIND_RESULT_FOR_S_IN_METHOD_S, CANNOT_RETURN_S_SHOULD_BE_OPTIONAL_S_OR_S, EXPECTED_SINGLE_RESULT, HANDLE_METHOD, LOOKS_LIKE_METHOD_WITHOUT_REQUIRED_PARAMETER_ID, NOT_SUPPORTED_RETURN_TYPE_FOR_METHOD_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata) Executes the given repository method using the provided parameters, repository details, and method metadata.private <T> TexecuteHelper(Class<T> entityClass, Object entity, BibernateSession bringSession) Helper method for executing the save operation on a BibernateSession instance.booleanisMethodHandle(Method method) Checks if the given method can be handled by this handler.
-
Field Details
-
METHOD_NAME
The prefix for the handled method (save).- See Also:
-
DELETE_METHOD_SHOULD_HAVE_ONE_PARAMETER_ID
- See Also:
-
-
Constructor Details
-
SimpleRepositoryMethodSaveHandler
public SimpleRepositoryMethodSaveHandler()
-
-
Method Details
-
isMethodHandle
Checks if the given method can be handled by this handler. Checks if the method name is "save".- Specified by:
isMethodHandlein interfaceSimpleRepositoryMethodHandler- Parameters:
method- The method to check.- Returns:
trueif this handler can handle the method,falseotherwise.
-
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 "save" method by saving an entity using the Bibernate session.- Specified by:
executein interfaceSimpleRepositoryMethodHandler- 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
Helper method for executing the save operation on a BibernateSession instance. Saves a single entity of the specified class using the provided BibernateSession.- Type Parameters:
T- the type of the entity being saved- Parameters:
entityClass- the class of the entity to be savedentity- the entity instance to be savedbringSession- the BibernateSession instance used for saving the entity- Returns:
- the saved entity
-