![]() Note: I do not send the null values from the client. I also tried changing var to val but the error still persists ![]() I also debugged, and the attributes are not initialized with their default values. TestImplementation "2:mockito-kotlin:2.2.0"Īnnotation("")Īnnotation("")īut still I get the issue indicating me, that Spring Boot isn't using my default values from data class. Plus, Kotlin has been supporting these operators since day one, making null safety one of the most important features coming with the language. I receive the data through following controller: book: BookItem): ResponseEntity " As shown, Kotlin comes with many operators and inbuilt functions to deal with null safety and offers you much freedom of action. Var publicationDate: Date = "id", nullable = GenerationType.SEQUENCE, generator = "sequenceGenerator") Var dateOfPurchase: Date = "publicationDate", nullable = false) Var status: BookStatus = "dateOfPurchase") Var price: Double? = "status", nullable = false) (We use nullable strings over empty strings. Var label: String? = "isReferenceOnly", nullable = false) Describe the solution youd like If a kotlin data class has a null string, please convert it to in the json. Var barcode: String = "label", unique = true) Var format: BookFormat = "barcode", nullable = false) One entity looks like that: package ĭata class BookItem = ) Now I can't update any Entity received through PUT/POST, because the data doesn't contain the default values from the data class I have started migrating a Spring Boot application from Java to Kotlin.
0 Comments
Leave a Reply. |