@@ -97,8 +97,9 @@ internal class MetadataParser(resolver: Resolver, environment: SymbolProcessorEn
97
97
98
98
_logger .info(" [ktorm-ksp-compiler] parse table metadata from entity: $className " )
99
99
val table = cls.getAnnotationsByType(Table ::class ).first()
100
- val (superClass, superTableClasses) = parseSuperTableClass(cls)
101
- val allPropertyNamesOfSuperTables = superTableClasses.flatMap { it.getProperties(emptySet()) }.map { it.simpleName.asString() }
100
+
101
+ val (finalSuperClass, allSuperTableClasses) = parseSuperTableClass(cls)
102
+ val shouldIgnorePropertyNames = allSuperTableClasses.flatMap { it.getProperties(emptySet()) }.map { it.simpleName.asString() }
102
103
103
104
val tableMetadata = TableMetadata (
104
105
entityClass = cls,
@@ -108,9 +109,9 @@ internal class MetadataParser(resolver: Resolver, environment: SymbolProcessorEn
108
109
schema = table.schema.ifEmpty { _options [" ktorm.schema" ] }?.takeIf { it.isNotEmpty() },
109
110
tableClassName = table.className.ifEmpty { _codingNamingStrategy .getTableClassName(cls) },
110
111
entitySequenceName = table.entitySequenceName.ifEmpty { _codingNamingStrategy .getEntitySequenceName(cls) },
111
- ignoreProperties = table.ignoreProperties.toSet() + allPropertyNamesOfSuperTables, // ignore properties of super tables
112
+ ignoreProperties = table.ignoreProperties.toSet() + shouldIgnorePropertyNames,
112
113
columns = ArrayList (),
113
- superClass = superClass
114
+ superClass = finalSuperClass
114
115
)
115
116
116
117
val columns = tableMetadata.columns as MutableList
@@ -283,14 +284,14 @@ internal class MetadataParser(resolver: Resolver, environment: SymbolProcessorEn
283
284
}
284
285
285
286
/* *
286
- * @return the super table class and all class be annotated with [SuperTableClass] in the inheritance hierarchy.
287
+ * @return the final super table class and all super table classes in the inheritance hierarchy.
287
288
*/
288
289
@OptIn(KotlinPoetKspPreview ::class )
289
290
private fun parseSuperTableClass (cls : KSClassDeclaration ): Pair <ClassName , Set <KSClassDeclaration >> {
290
- val superTableClassAnnPair = cls.findAllAnnotationsInInheritanceHierarchy (SuperTableClass ::class .qualifiedName!! )
291
+ val entityAnnPairs = cls.findAnnotationsInHierarchy (SuperTableClass ::class .qualifiedName!! )
291
292
292
293
// if there is no SuperTableClass annotation, return the default super table class based on the class kind.
293
- if (superTableClassAnnPair .isEmpty()) {
294
+ if (entityAnnPairs .isEmpty()) {
294
295
return if (cls.classKind == INTERFACE ) {
295
296
org.ktorm.schema.Table ::class .asClassName() to emptySet()
296
297
} else {
@@ -299,13 +300,13 @@ internal class MetadataParser(resolver: Resolver, environment: SymbolProcessorEn
299
300
}
300
301
301
302
// SuperTableClass annotation can only be used on interface
302
- if (superTableClassAnnPair .map { it.first }.any { it.classKind != INTERFACE }) {
303
+ if (entityAnnPairs .map { it.first }.any { it.classKind != INTERFACE }) {
303
304
val msg = " SuperTableClass annotation can only be used on interface."
304
305
throw IllegalArgumentException (msg)
305
306
}
306
307
307
308
// find the last annotation in the inheritance hierarchy
308
- val superTableClasses = superTableClassAnnPair
309
+ val superTableClasses = entityAnnPairs
309
310
.map { it.second }
310
311
.map { it.arguments.single { it.name?.asString() == SuperTableClass ::value.name } }
311
312
.map { it.value as KSType }
0 commit comments