Skip to content

Lazy DBref does not work with kotlin data classes having an immutable id property [DATAMONGO-2654] #3507

Open
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Labels

in: kotlinKotlin supportin: mappingMapping and conversion infrastructuretype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions