Class DefaultMetaDataEngine

java.lang.Object
org.litebridge.db.spi.impl.engine.DefaultMetaDataEngine
All Implemented Interfaces:
MetaDataEngine

public class DefaultMetaDataEngine extends Object implements MetaDataEngine
  • Constructor Details

  • Method Details

    • metaData

      public DatabaseProviderMetaData metaData()
      Description copied from interface: MetaDataEngine
      Retrieve metadata/capabilities of this database provider.
      Specified by:
      metaData in interface MetaDataEngine
      Returns:
      metadata for this database provider.
    • databaseMetaData

      public DatabaseMetaData databaseMetaData(ConnectionProvider connectionProvider)
      Description copied from interface: MetaDataEngine
      Retrieve metadata for the connected database.
      Specified by:
      databaseMetaData in interface MetaDataEngine
      Parameters:
      connectionProvider - the ConnectionProvider used to get a database connection.
      Returns:
      a DatabaseMetaData object containing information about the connected database.
    • ensureTableMetaData

      public TableMetaData ensureTableMetaData(Table table, ConnectionProvider connectionProvider)
      Description copied from interface: MetaDataEngine
      Ensure that table metadata is available for the specified table, fetching it if not already cached.
      Specified by:
      ensureTableMetaData in interface MetaDataEngine
      Parameters:
      table - the Table object representing the table
      connectionProvider - the ConnectionProvider used to fetch metadata if needed
      Returns:
      the TableMetaData for the table
    • fetchTableMetaData

      protected TableMetaData fetchTableMetaData(Table table, ConnectionProvider connectionProvider) throws SQLException
      Retrieve metadata for the specified table, including its primary keys and expressions.

      This executes a database query to fetch database metadata.

      Parameters:
      table - the table for which metadata is being fetched, containing schema, catalog, and table name details
      connectionProvider - the ConnectionProvider used to obtain a database connection.
      Returns:
      a TableMetaData object containing details about the table's structure, primary keys, and column metadata
      Throws:
      SQLException - if an error occurs while fetching database metadata
    • verifySchemaAndTableExists

      protected static void verifySchemaAndTableExists(Table table, DatabaseMetaData databaseMetaData) throws SQLException
      Verify that the specified schema and table exist in the database.
      Parameters:
      table - the Table object representing the table to verify
      databaseMetaData - the DatabaseMetaData object used to perform the verification
      Throws:
      SQLException - if an error occurs while performing the verification
      IllegalArgumentException - if the schema or table is not found
    • getColumnMetaData

      protected List<ColumnMetaData> getColumnMetaData(Table table, DatabaseMetaData databaseMetaData) throws SQLException
      Retrieve column metadata for the specified table.
      Parameters:
      table - the Table object representing the table
      databaseMetaData - the DatabaseMetaData object used to retrieve column information
      Returns:
      a list of ColumnMetaData objects representing the table's columns
      Throws:
      SQLException - if an error occurs while retrieving column metadata
    • getPrimaryKeyColumnNames

      protected List<String> getPrimaryKeyColumnNames(Table table, DatabaseMetaData databaseMetaData) throws SQLException
      Retrieve the names of the primary key columns for the specified table.
      Parameters:
      table - the Table object representing the table
      databaseMetaData - the DatabaseMetaData object used to retrieve primary key information
      Returns:
      a list of primary key column names
      Throws:
      SQLException - if an error occurs while retrieving primary key information
    • createDatabaseMetaData

      protected DatabaseMetaData createDatabaseMetaData(ConnectionProvider connectionProvider)