Class NoRelationFieldResolver

java.lang.Object
io.github.blyznytsiaorg.bibernate.ddl.field.NoRelationFieldResolver
All Implemented Interfaces:
FieldResolver

public class NoRelationFieldResolver extends Object implements FieldResolver
The NoRelationFieldResolver class implements the FieldResolver interface to handle fields that are not part of any relationship mapping.
Since:
1.0
Author:
Blyzhnytsia Team
See Also:
  • Field Details

  • Constructor Details

    • NoRelationFieldResolver

      public NoRelationFieldResolver()
  • Method Details

    • hasFieldToResolve

      public boolean hasFieldToResolve(EntityColumnDetails entityColumnDetails)
      Checks if the given entity column details represent a field that needs resolution. This method returns true if the entity column details do not correspond to any relationship mappings, such as @OneToOne, @ManyToOne, @OneToMany, or @ManyToMany.
      Specified by:
      hasFieldToResolve in interface FieldResolver
      Parameters:
      entityColumnDetails - The entity column details to be checked.
      Returns:
      True if the field needs resolution, false otherwise.
    • handleField

      public void handleField(DDLFieldMetadataHolder metadataHolder, Map<Integer,List<String>> ddlMetadata)
      Handles the resolution of the given entity column details by generating database type information and adding it to the list of column name and database type.
      Specified by:
      handleField in interface FieldResolver
      Parameters:
      metadataHolder - The holder containing metadata related to the field.
      ddlMetadata - The map storing DDL metadata.
    • processIdField

      private String processIdField(String tableName, EntityColumnDetails entityColumn, Map<Integer,List<String>> ddlMetadata)
      Processes the ID field by generating the database type information.
      Parameters:
      tableName - The name of the table.
      entityColumn - The entity column details.
      ddlMetadata - The map storing DDL metadata.
      Returns:
      The generated database type information for the ID field.
    • generateSequence

      private void generateSequence(GeneratedValueMetadata generatedValue, SequenceGeneratorMetadata sequenceGenerator, String tableName, String columnName, Map<Integer,List<String>> ddlMetadata)
      Generates the sequence for the ID field if necessary and adds it to the DDL metadata.
      Parameters:
      generatedValue - The metadata for the generated value.
      sequenceGenerator - The metadata for the sequence generator.
      tableName - The name of the table.
      columnName - The name of the column.
      ddlMetadata - The map storing DDL metadata.
    • checkForDuplicateNameSequence

      private void checkForDuplicateNameSequence(Map<Integer,List<String>> ddlMetadata, String sequenceNameDefault)
      Checks if there is a duplicate sequence name in the DDL metadata and throws an exception if found.
      Parameters:
      ddlMetadata - The map storing DDL metadata.
      sequenceNameDefault - The name of the sequence to check for duplicates.
      Throws:
      MappingException - if a duplicate sequence name is found.
    • processTimestamp

      private String processTimestamp(EntityColumnDetails entityColumn)
      Processes a timestamp column for database creation.
      Parameters:
      entityColumn - The details of the entity column.
      Returns:
      The formatted string representing the timestamp column.
    • isCreationTimestamp

      private boolean isCreationTimestamp(EntityColumnDetails entityColumn)
      Checks if the timestamp column is marked for creation timestamp.
      Parameters:
      entityColumn - The details of the entity column.
      Returns:
      True if the column is marked for creation timestamp, false otherwise.
    • getColumnNameDatabaseType

      private String getColumnNameDatabaseType(EntityColumnDetails entityColumn)
      Gets the formatted string representing the column name and its database type.
      Parameters:
      entityColumn - The details of the entity column.
      Returns:
      The formatted string representing the column name and its database type.