Enum Class DeleteByIdQueryGenerator
java.lang.Object
java.lang.Enum<DeleteByIdQueryGenerator>
dimstyl.orm.internal.sql.generator.DeleteByIdQueryGenerator
- All Implemented Interfaces:
SqlQueryGenerator<Optional<String>,
,RepositoryMetadata> Serializable
,Comparable<DeleteByIdQueryGenerator>
,Constable
enum DeleteByIdQueryGenerator
extends Enum<DeleteByIdQueryGenerator>
implements SqlQueryGenerator<Optional<String>,RepositoryMetadata>
Generates an SQL `DELETE FROM` query for deleting an entity by its primary key.
This generator ensures that the repository supports the `DELETE_BY_ID` operation before creating the query. If the operation is not supported, query generation is skipped.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate
(RepositoryMetadata repositoryMetadata) Generates an SQL `DELETE BY ID` query for a given entity repository.static DeleteByIdQueryGenerator
Returns the enum constant of this class with the specified name.static DeleteByIdQueryGenerator[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
The singleton instance of the DeleteByIdQueryGenerator.
-
-
Constructor Details
-
DeleteByIdQueryGenerator
private DeleteByIdQueryGenerator()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
generate
public Optional<String> generate(RepositoryMetadata repositoryMetadata) throws CompositePrimaryKeyException, MissingColumnAnnotationException, MissingPrimaryKeyException Generates an SQL `DELETE BY ID` query for a given entity repository.The method checks if the repository supports the `DELETE_BY_ID` operation before proceeding. If the entity has a composite primary key, an exception is thrown since this method only supports single-column primary keys.
- Specified by:
generate
in interfaceSqlQueryGenerator<Optional<String>,
RepositoryMetadata> - Parameters:
repositoryMetadata
- Metadata about the repository, including table and entity information, as defined byRepositoryMetadata
.- Returns:
- An
Optional
containing the SQL query if the `DELETE_BY_ID` operation is supported, otherwise an emptyOptional
. - Throws:
CompositePrimaryKeyException
- If the entity has a composite primary key.MissingColumnAnnotationException
- If the primary key field is missing the requiredColumn
annotation.MissingPrimaryKeyException
- If the entity does not have a defined primary key.
-