Filter delegated properties for Kotlin data classes.

We now filter delegated properties (such as lazy) from being managed as persistent properties.

Closes #3112
This commit is contained in:
Mark Paluch
2024-06-24 11:41:46 +02:00
parent df2276a19d
commit a115ee6a44
4 changed files with 81 additions and 3 deletions

View File

@@ -314,7 +314,7 @@ Consider the following `data` class `Person`:
data class Person(val id: String, val name: String)
----
The class above compiles to a typical class with an explicit constructor.We can customize this class by adding another constructor and annotate it with `@PersistenceCreator` to indicate a constructor preference:
The class above compiles to a typical class with an explicit constructor. We can customize this class by adding another constructor and annotate it with `@PersistenceCreator` to indicate a constructor preference:
[source,kotlin]
----
@@ -335,6 +335,9 @@ data class Person(var id: String, val name: String = "unknown")
Every time the `name` parameter is either not part of the result or its value is `null`, then the `name` defaults to `unknown`.
NOTE: Delegated properties are not supported with Spring Data. The mapping metadata filters delegated properties for Kotlin Data classes.
In all other cases you can exclude synthetic fields for delegated properties by annotating the property with `@delegate:org.springframework.data.annotation.Transient`.
[[property-population-of-kotlin-data-classes]]
=== Property population of Kotlin data classes