You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current operation of the Jdbc*Daos is a bit awkward, especially when JSON is used:
We have two different columns SHORT_CONTEXT with a default limit of 2500 and SERIALIZED_CONTEXT of unlimited size. Both of them use character based data types. If SERIALIZED_CONTEXT is set then SHORT_CONTEXT contains invalid, non-parseable, data because it has been truncated and " ..." has been appended.
If JSON is used then the JacksonExecutionContextStringSerializer serializes to a UTF-8 byte array. The Jdbc*Daos then use the configured encoding to convert the UTF-8 byte array to a String. To be correct the same encoding has to be used. Using JSON has several advantages, most notability that that modern SQL has JSON querying capabilities. This can be helpful for analysis during incidents.
If the DefaultExecutionContextSerializer is used then it produces a Base64 byte array which the Jdbc*Daos then convert to a string using the given encoding.
Given the character based nature of the columns using a byte oriented abstraction like Serializer and Deserializer for ExecutionContextSerializer does not seem intuitive. Something like org.springframework.core.convert.converter.Converter<Map<String, Object>, String> would be much more intuitive, unfortunately it supports only one way.
We are now at the point in time where several widely adopted relational databases (H2, MariaDB, MySQL, Oracle, PostgreS, SQL Server) support JSON natively as a data type for columns. However to use this several things have to change:
The SHORT_CONTEXT, SERIALIZED_CONTEXT distinction has to go. Native JSON datatypes enforce valid JSON documents, therefore no truncation must happen.
The Map<String, Object> -> byte[] -> String conversion has to be replaced with something more customizable. Some drivers directly support writing and reading jakarta.json.JsonObject, dealing directly with pre-parsed JSON data and avoiding the need for JSON-parsing.
DDLs have to be adjusted accordingly, where applicable a choice between json and jsonb has to be made.
While the changes may seem small on the surface I don't see an easy way to retrofit this in a non-breaking way. I also have no good answer of how to support DefaultExecutionContextSerializer other than with its own dedicated column, which again would make the Daos more complicated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
The current operation of the Jdbc*Daos is a bit awkward, especially when JSON is used:
SHORT_CONTEXTwith a default limit of 2500 andSERIALIZED_CONTEXTof unlimited size. Both of them use character based data types. IfSERIALIZED_CONTEXTis set thenSHORT_CONTEXTcontains invalid, non-parseable, data because it has been truncated and" ..."has been appended.JacksonExecutionContextStringSerializerserializes to a UTF-8 byte array. The Jdbc*Daos then use the configured encoding to convert the UTF-8 byte array to a String. To be correct the same encoding has to be used. Using JSON has several advantages, most notability that that modern SQL has JSON querying capabilities. This can be helpful for analysis during incidents.DefaultExecutionContextSerializeris used then it produces a Base64 byte array which the Jdbc*Daos then convert to a string using the given encoding.SerializerandDeserializerforExecutionContextSerializerdoes not seem intuitive. Something likeorg.springframework.core.convert.converter.Converter<Map<String, Object>, String>would be much more intuitive, unfortunately it supports only one way.We are now at the point in time where several widely adopted relational databases (H2, MariaDB, MySQL, Oracle, PostgreS, SQL Server) support JSON natively as a data type for columns. However to use this several things have to change:
SHORT_CONTEXT,SERIALIZED_CONTEXTdistinction has to go. Native JSON datatypes enforce valid JSON documents, therefore no truncation must happen.Map<String, Object>->byte[]->Stringconversion has to be replaced with something more customizable. Some drivers directly support writing and readingjakarta.json.JsonObject, dealing directly with pre-parsed JSON data and avoiding the need for JSON-parsing.jsonandjsonbhas to be made.While the changes may seem small on the surface I don't see an easy way to retrofit this in a non-breaking way. I also have no good answer of how to support
DefaultExecutionContextSerializerother than with its own dedicated column, which again would make the Daos more complicated.All reactions