Note: I do not send the null values from the client. I also tried changing var to val but the error still persists For example, Nullable string can be declared by. I also debugged, and the attributes are not initialized with their default values. To make a reference as null, kotlin has separate reference type for each of the type known as Nullable type. 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. I receive the data through following controller: book: BookItem): ResponseEntity " Var publicationDate: Date = "id", nullable = GenerationType.SEQUENCE, generator = "sequenceGenerator") Var dateOfPurchase: Date = "publicationDate", nullable = false) Plus, Kotlin has been supporting these operators since day one, making null safety one of the most important features coming with the language. Var status: BookStatus = "dateOfPurchase") As shown, Kotlin comes with many operators and inbuilt functions to deal with null safety and offers you much freedom of action. Var price: Double? = "status", nullable = false) ![]() Var label: String? = "isReferenceOnly", nullable = false) 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. |