java.lang.Object
org.litebridgedb.orm.persistence.OrmTable
A table known by/registered with the ORM, facilitating the relationship between Java objects (DTOs)
and database table schema.
This class maintains metadata and mappings between object field accessors and database columns. It tracks changes made to objects and their associated database states for ORM operations.
-
Constructor Summary
ConstructorsConstructorDescriptionOrmTable(Class<?> dtoClass, TableMetaData metaData, Map<FieldAccessor, MappedFieldTarget> fieldTargetMap, ChangeTracker changeTracker, ClassFieldAccessorCache classFieldAccessorCache) Constructs a newOrmTableinstance, initializing table metadata, field-to-column mappings, and a change tracker for managing object state. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOneToManyReverseMapping(FieldAccessor fieldAccessor) Class<?> dtoClass()Get the DTO class associated with the table.<DTO> TrackedDto<DTO> ensureTrackedDto(DTO dto) Get the tracked version of the specified DTO, tracking its fields if not already tracked.@Nullable FieldAccessorfieldForColumnNameOrNull(String columnName) Get the column metadata for the specified column name.getColumnForFieldName(String fieldName) Get the column metadata for the specified field name.getFieldForColumnName(String columnName) Get the field accessor for the specified column name.final List<MappedManyToMany> Get the table metadata.final List<MappedOneToMany> @Nullable List<FieldAccessor> <DTO> TrackedDto<DTO> getTrackedDto(DTO dto) Get the tracked version of the specified DTO.booleanisPersistedDto(Object dto) Check if the specified DTO is persisted.voidsyncPersistedDto(Object dto) Mark the specified DTO as persisted, creating a snapshot for tracking changes.voidTrack the specified DTO's fields.
-
Constructor Details
-
OrmTable
public OrmTable(Class<?> dtoClass, TableMetaData metaData, Map<FieldAccessor, MappedFieldTarget> fieldTargetMap, ChangeTracker changeTracker, ClassFieldAccessorCache classFieldAccessorCache) Constructs a newOrmTableinstance, initializing table metadata, field-to-column mappings, and a change tracker for managing object state.- Parameters:
dtoClass- the DTO class associated with the tablemetaData- the metadata describing the table structurefieldTargetMap- a map associating field accessors with their corresponding column metadatachangeTracker- the change tracker to monitor and track modifications made to the table's data
-
-
Method Details
-
dtoClass
Get the DTO class associated with the table.- Returns:
- the DTO class associated with the table
-
getMetaData
Get the table metadata.- Returns:
- the table metadata
-
getColumnForFieldName
Get the column metadata for the specified field name.- Parameters:
fieldName- the field name to retrieve the column metadata for- Returns:
- the column metadata for the specified field name, or null if not found
-
getNestedDtoClasses
-
getColumn
Get the column metadata for the specified column name.- Parameters:
columnName- the column name to retrieve the metadata for- Returns:
- the column metadata for the specified column name, or null if not found
-
getTrackedDto
Get the tracked version of the specified DTO.- Type Parameters:
DTO- the type of the DTO- Parameters:
dto- the DTO to retrieve the tracked version for- Returns:
- the tracked version of the specified DTO
- Throws:
IllegalArgumentException- if the specified DTO is not tracked
-
ensureTrackedDto
Get the tracked version of the specified DTO, tracking its fields if not already tracked.- Type Parameters:
DTO- the type of the DTO- Parameters:
dto- the DTO to retrieve the tracked version for- Returns:
- the tracked version of the specified DTO
-
trackDto
Track the specified DTO's fields.- Parameters:
dto- the DTO to track
-
getFieldForColumnName
Get the field accessor for the specified column name.- Parameters:
columnName- the column name to retrieve the field accessor for- Returns:
- the field accessor for the specified column name, or null if not found
- Throws:
IllegalArgumentException- if the specified column name is null or empty
-
fieldForColumnNameOrNull
-
fieldAcessorStream
-
syncPersistedDto
Mark the specified DTO as persisted, creating a snapshot for tracking changes.- Parameters:
dto- the DTO to mark as persisted- Throws:
IllegalArgumentException- if the specified DTO is null
-
isPersistedDto
Check if the specified DTO is persisted.- Parameters:
dto- the DTO to check- Returns:
- true if the specified DTO is persisted, false otherwise
- Throws:
IllegalArgumentException- if the specified DTO is null
-
getOneToManyMappings
-
getManyToManyMappings
-
getOneToManyMappingForField
-
getManyToManyMappingForField
-
mappedFieldTargets
-
getContextTableRegistry
-
addOneToManyReverseMapping
-
getOneToManyReverseMappings
-