#1338: EntityInfo.kt

projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/metamodel/EntityInfo.kt Metamodel Entity — JPA Persistence Metamodel, projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/metamodel/EntityInfo.kt 111 lines · 71 code · 27 comments · 13 blank
Wraps a JPA EntityType to provide introspective access to entity metadata: property discovery, annotation inspection, column length lookups, and persistence checks. Used by the import subsystem and persistence layer to dynamically map between imported data and JPA entity properties.

Architecture

Class Design

EntityInfo wraps a JPA EntityType<*> and eagerly populates a list of EntityPropertyInfo objects for each JPA attribute that has a javaMember. It serves as a bridge between JPA's metamodel and ProjectForge's runtime reflection needs.

Constructor Parameters

ParameterTypePurpose
entityClassClass<*>The Java/Kotlin class of the entity
nameStringEntity name (typically the JPA entity name)
entityTypeEntityType<*>JPA metamodel type providing attribute access
tableNameString?Optional database table name

Core Methods

MethodReturnDescription
getIdProperty()String?Returns the name of the ID property (first property marked as ID)
isPersistedProperty(property: KCallable)BooleanChecks if a Kotlin callable corresponds to a persisted JPA attribute
isPersistedProperty(propertyName: String)BooleanChecks by property name
getPropertyInfo(propertyName)EntityPropertyInfo?Retrieves full property metadata
getPropertiesWithAnnotation(annotationClass)List<EntityPropertyInfo>Finds all properties bearing a specific annotation
getColumnAnnotation(propertyName)Column?Retrieves the JPA @Column annotation
getColumnLength(propertyName)Int?Extracts column length from @Column(length=...); logs warning on failures for DO entities

Kotlin Reflection Integration

The class supports both string-based property lookups and Kotlin reflection (KCallable, KMutableProperty1). The isPersistedProperty overloads allow callers to check whether a Kotlin property corresponds to a JPA column, which is essential for the import subsystem's automatic property mapping.

Caching for Column Length

getColumnLength() uses an internal columnWithoutLength set to avoid repeated log messages when a property has no @Column annotation. Properties ending in "DO" are logged at ERROR level, others at INFO level — treating DO entities as expected to have full JPA annotations.

Relationships

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
bbc198d03 Migration stuff in progress... (all tests of all packages: OK).
e801b0336 Migration stuff in progress...
efee0def3 Migration stuff in progress...
eb4e16a33 Migration stuff in progress...
ca4cb86c8 Migration stuff in progress...
e4545c8e1 Migration stuff in progress...
7f86d3730 Migration stuff in progress...
d476c7b0d Migration stuff in progress...
067a4cbb1 Migration stuff in progress...
67ce75fe9 Migration stuff in progress...