Skip to content
Advertisement

Correct value of a json data saved using JPA, spring and kotlin Map

I have a jsonb column in a postgres database where I store a bunch of key/value(1 level) into a column mappped to a a Map<String, Any).

The values are supposed to be a String but in code I’m accepting anything. All saved values was passed as ByteArray(byte[]) and it’s stored without problems.

The stored value is transformed to a String and it’s different from the one expected. For example When I store a mapOf(“verion” to “1.0”.toByteArray()) I’m getting this => ‘{“version”:”MS4w”}’

I can fix the code to convert the byte[] to a String before persisting.

the entity was mapped like this:

the table:

My question: is there a way to correct all values of the data stored dynamically, exp: update “MS4w” => “1.0” and other values using a query or a procedure?

It seems that the value are encoded in Base64 enter image description here

Thanks in advance.

Advertisement

Answer

Running this function should fix the data values encoded to base64:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement