Different ways to create data classes for JPA


I have been trying to create ideal model class for Spring Data. I looked at data class and constructors documentation, but I think that after M11 release it should be upgraded. Now it is possible to create secondary parameterless constructor.

Sample code:

Document(collection = “test”)
public data class Test (
  Id val id: String? = null,
  val name: String,
  val parent: String? = null
) : Serializable {
  private constructor() : this(name = “”) {

This class works with Spring Data without any problems.Additionally when you want to create instance of this class we have to specify all required parameters (name in this case), which is not possible on samples presented in official documentation.

Do you think it is good solution or do you have other ideas how to implement it.