Description
Thorsten Hake opened DATAMONGO-2654 and commented
Referring with @DBRef(lazy=true)
to a kotlin data class having an immutable id property does not work as expected. During the initialization of the ID property, the whole data class will be loaded from MongoDB. The developer won't be notified about this behavior.
The root cause of this is the usage of the copy method of kotlin data classes to set the ID property. Upon calling the copy method of the data class, the data class will access all properties (except the id) of the generated LazyLoadingProxy
proxy. The LazyLoadingInterceptor
will intercept those calls to the properties and loads the whole kotlin data class.
The property accessor generated by ClassGeneratorPropertyAccessorFactory
will by default call the copy
method for immutable kotlin data properties (see PropertyAccessorClassGenerator.visitSetProperty0
).
No further details from DATAMONGO-2654