registerAnnotatedTypes
Finds the classes in packages and their subpackages annotated with PgEnumType, PgCompositeType or DynamicallyMappable, and registers each with this client, as typeManager.registerEnum, registerAutoComposite and dynamicTypes.register would.
val db = OctaviusClient.fromDataSource(dataSource)
db.dynamicTypes.install()
val found = db.registerAnnotatedTypes("com.roma.domain", "com.roma.dto")
logger.info { "Octavius registered $found" }Content copied to clipboard
A name the database has no type for is registered all the same and reported in ScanReport.unresolved. Registration belongs to the database, so this runs once, at startup.
Throws
INVALID_ARGUMENT where no package was named, or where an annotation sits on a class it cannot describe.
fun OctaviusClient.registerAnnotatedTypes(packages: List<String>, classLoader: ClassLoader? = null): ScanReport
As the vararg overload, looking for the classes in classLoader: for an application whose classes are not on the loader that loaded this one, such as an OSGi container or a plugin host. null uses the default.