Class DDLQueryCreator

java.lang.Object
io.github.blyznytsiaorg.bibernate.ddl.DDLQueryCreator

public class DDLQueryCreator extends Object
The DDLQueryCreator class is responsible for creating Data Definition Language (DDL) queries based on the metadata of entities in the Bibernate framework. It generates queries for operations such as creating and dropping tables, indexes and sequences. Additionally, it handles the resolution of field mappings and the creation of queries based on entity metadata.

This class also provides methods for validating and creating DDL queries for various database operations.

The DDLQueryCreator class is designed to work in conjunction with other components of the Bibernate framework to facilitate database schema management and migration tasks.

Since:
1.0
Author:
Blyzhnytsia Team
See Also:
  • Field Details

  • Constructor Details

    • DDLQueryCreator

      public DDLQueryCreator()
      Constructs a new DDLQueryCreator instance.

      Initializes the DDL query metadata map and field resolvers list. Retrieves Bibernate entity metadata and sets up DDL metadata for various operations such as dropping constraints, tables and sequences, as well as creating sequences, tables, indexes and constraints. Finally, it invokes the createQueries() method to generate the DDL queries based on the entity metadata.

      See Also:
  • Method Details

    • createQueries

      public void createQueries()
      Generates Data Definition Language (DDL) queries based on the metadata of Bibernate entities.

      Iterates over each Bibernate entity metadata and creates DDL queries for operations such as dropping tables, creating tables and creating indexes. For each entity, it creates DDL queries for its columns and resolves any associated field mappings using field resolvers.

      The generated DDL queries are added to the respective lists in the DDL metadata map for further processing.

      Since:
      1.0
      See Also:
    • createIndexQuery

      private void createIndexQuery(EntityMetadata entityMetadata)
      Creates Data Definition Language (DDL) queries for creating indexes on the specified entity table.
      Parameters:
      entityMetadata - the metadata of the entity for which indexes are created
    • checkIfColumnForIndexExists

      private void checkIfColumnForIndexExists(EntityMetadata entityMetadata, String columnList)
      Checks if the specified column exists in the entity metadata for creating an index.

      Verifies whether the specified column exists in the entity metadata list of columns. If the column does not exist, it throws a MappingException indicating that the column does not exist for creating an index.

      Parameters:
      entityMetadata - the metadata of the entity
      columnList - the list of columns for which the index is being created
      Throws:
      MappingException - if the specified column does not exist in the entity metadata