![]() ![]() Yes there are some hacks like changing "" to " " but I’d rather invent a random name for the guy than persisting a whitespace. There is no magic configuration to tell Oracle how you want to handle empty strings. The funny thing about this one is that there is not much you can do about it. This is probably only possible because Hibernate is using reflection to set the field value in runtime, thus breaking Kotlin’s null safety. So when the data was mapped back to my Person object I ended up with a null value for name. Oracle simply won't let insert an empty string. This is because Oracle internally changes empty string to NULL values. Persisting to OracleDB (instead of embedded H2). ![]() But we finally figured out what was happening when we notice it was only reproducible under the following conditions: ![]() To make things more difficult there where other failures in the communication layer masking the real issue. Tests where passing with flying colors, but for some reason we were noticing that the name would sometimes come back as null even thought it was typed as String and not String?. So I had modeled the following Entity leveraging Kotlin’s data classes 1: Let’s start by setting the stage, for this particular project I was working with the following stack: This is the story of how Oracle DB was messing up Kotlin’s type system, and what I did to fix it. H2, jpa, kotlin, npe, nulls, oracle, oracle-db, spring, spring-data ![]()
0 Comments
Leave a Reply. |