@@ -391,51 +391,48 @@ you will be able to write your Kotlin beans without any additional `open` keywor
391391
392392=== Using immutable class instances for persistence
393393
394- In Kotlin, it is very convenient and considered best practice to declare
395- read-only properties within the primary constructor, as in the following
396- example:
394+ In Kotlin, it is very convenient and considered best practice to declare read-only properties
395+ within the primary constructor, as in the following example:
397396
398397[source,kotlin]
399398----
400399class Person(val name: String, val age: Int)
401400----
402401
403402You can optionally add https://kotlinlang.org/docs/reference/data-classes.html[the `data` keyword]
404- to make the compiler automatically derives the following members from all properties
405- declared in the primary constructor:
403+ to make the compiler automatically derive the following members from all properties declared
404+ in the primary constructor:
406405
407406* equals()/hashCode() pair
408407* toString() of the form "User(name=John, age=42)"
409408* componentN() functions corresponding to the properties in their order of declaration
410409* copy() function
411410
412- This allows to change easily just one of the properties even if `User` properties are read-only:
413- his allows us to write:
414-
411+ This allows for easy changes to individual properties even if `Person` properties are read-only:
415412
416413[source,kotlin]
417414----
418415data class Person(val name: String, val age: Int)
419416
420- val jack = User (name = "Jack", age = 1)
417+ val jack = Person (name = "Jack", age = 1)
421418val olderJack = jack.copy(age = 2)
422419----
423420
424- But some persistence technologies like JPA require a default constructor, preventing this
421+ Common persistence technologies such as JPA require a default constructor, preventing this
425422kind of design. Fortunately, there is now a workaround for this
426423https://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell["default constructor hell"]
427424since Kotlin provides a https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-jpa-compiler-plugin[kotlin-jpa]
428425plugin which generates synthetic no-arg constructor for classes annotated with JPA annotations.
429426
430- If you need to leverage this kind of mechanism for other persistence technologies, you can
431- configure https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
427+ If you need to leverage this kind of mechanism for other persistence technologies, you can configure
428+ the https://kotlinlang.org/docs/reference/compiler-plugins.html#how-to-use-no-arg-plugin[kotlin-noarg]
432429plugin.
433430
434431[NOTE]
435432====
436- As of Kay release train, Spring Data supports Kotlin immutable class instances
437- and should not require `kotlin-noarg` plugin if the module leverages Spring Data object
438- mapping (like with MongoDB, Redis, Cassandra, etc. ).
433+ As of the Kay release train, Spring Data supports Kotlin immutable class instances and
434+ does not require the `kotlin-noarg` plugin if the module leverages Spring Data object
435+ mappings (like with MongoDB, Redis, Cassandra, etc).
439436====
440437
441438
0 commit comments