Open
Description
Johan Haleby opened DATAMONGO-2395 and commented
Hi,
In Spring Data MongoDB 2.1.x I have code that looks like this:
fun createCollectionsIfNotExists(vararg entityClasses: KClass<*>) = entityClasses.forEach { entityClass ->
if (!mongo.collectionExists(entityClass)) {
mongo.createCollection(entityClass)
}
}
createCollectionsIfNotExists(MongoDTO1::class, MongoDTO2::class, MongoDTO3::class, MongoDTO4::class)
In 2.2 "collectionExists" and "createCollection" has been deprecated in favor of reified counterparts. However invoking the reified methods is difficult if you just have "KClass" (see https://stackoverflow.com/questions/55399737/calling-a-fun-with-reified-type-parameter-if-you-just-have-a-kclass-object). Is there a recommended approach to deal with situations like the one I have in 2.2 or could both method variants be retained (i.e. both KClass and the reified version)?
Affects: 2.2 GA (Moore)