diff --git a/exposed-dao/src/main/kotlin/org/jetbrains/exposed/dao/References.kt b/exposed-dao/src/main/kotlin/org/jetbrains/exposed/dao/References.kt index 4d6196e28d..9d49e7dccf 100644 --- a/exposed-dao/src/main/kotlin/org/jetbrains/exposed/dao/References.kt +++ b/exposed-dao/src/main/kotlin/org/jetbrains/exposed/dao/References.kt @@ -223,6 +223,9 @@ private fun > List>.preloadRelations( fun , SRC : Entity, REF : Entity<*>> Iterable.with(vararg relations: KProperty1): Iterable = toList().apply { + if (any { it.isNewEntity() }) { + TransactionManager.current().flushCache() + } preloadRelations(*relations) }