Class TableMapper

java.lang.Object
org.litebridge.orm.persistence.TableMapper

public final class TableMapper extends Object
A utility class responsible for mapping DTOs to database tables and managing the relationships between them.

The primary function of this class is to provide mappings for various table specifications, handle entity relationships like one-to-many and many-to-many mappings, and facilitate metadata management for database operations.

  • Constructor Details

  • Method Details

    • mapToTable

      public TableMapper.MappedTable mapToTable(MethodHandles.Lookup lookup, Class<?> dtoClass, TableSpec tableSpec, Set<Class<?>> allDtoClasses)
      Maps a Data Transfer Object (DTO) class to a database table based on the provided specification.

      Performs validation, ensures proper module accessibility, and generates metadata necessary for runtime table interactions.

      Parameters:
      lookup - the MethodHandles.Lookup instance for reflection; must not be null
      dtoClass - the DTO class to be mapped to the database table; must not be null
      tableSpec - the specification of the database table, including field-column mappings; must not be null
      allDtoClasses - a set of all DTO classes involved in the ORM mapping; must not be null
      Returns:
      a TableMapper.MappedTable instance representing the mapped table and its dependencies
      Throws:
      NullPointerException - if any of the required arguments are null
      IllegalArgumentException - if the DTO class is invalid or the table specification is incomplete
      IllegalStateException - if the table metadata cannot be read due to a database access issue