java.lang.Object
org.litebridge.orm.persistence.TableMapper
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA database table and its corresponding relationships mapped within the ORM (Object-Relational Mapping) layer. -
Constructor Summary
ConstructorsConstructorDescriptionTableMapper(TransactionalDatabaseProvider databaseProvider, TableRegistry tableRegistry, ChangeTracker changeTracker) -
Method Summary
Modifier and TypeMethodDescriptionmapToTable(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.
-
Constructor Details
-
TableMapper
public TableMapper(TransactionalDatabaseProvider databaseProvider, TableRegistry tableRegistry, ChangeTracker changeTracker)
-
-
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- theMethodHandles.Lookupinstance for reflection; must not be nulldtoClass- the DTO class to be mapped to the database table; must not be nulltableSpec- the specification of the database table, including field-column mappings; must not be nullallDtoClasses- a set of all DTO classes involved in the ORM mapping; must not be null- Returns:
- a
TableMapper.MappedTableinstance representing the mapped table and its dependencies - Throws:
NullPointerException- if any of the required arguments are nullIllegalArgumentException- if the DTO class is invalid or the table specification is incompleteIllegalStateException- if the table metadata cannot be read due to a database access issue
-