Field formatting expressions that allow for formatting a
Field when embedding it in SQLDataType.JSON,
SQLDataType.JSONB, or SQLDataType.XML.
Implementations should ensure:
- That
FormatterContext.multiset()vs non-multiset specific behaviour is distinguished, if necessary - That
NULLbehaviour is maintained.
Comparison to other API types
Unlike Formattable, which talks about formatting data to JSON, XML,
and other text types in the client using Java, the Formatter takes
care of doing this directly in SQL.
Unlike Converter, the formatting affects how the RDBMS embeds the
value into a JSON or XML datastructure before sending the data to
the client. A Converter is applied only after fetching data from
JDBC.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescriptionvoidFormat theFormatterContext.field()expression to embed it in aSQLDataType.JSONcontext.voidFormat theFormatterContext.field()expression to embed it in aSQLDataType.JSONBcontext.voidFormat theFormatterContext.field()expression to embed it in aSQLDataType.XMLcontext.
-
Method Details
-
formatJSON
Format theFormatterContext.field()expression to embed it in aSQLDataType.JSONcontext.If applicable, a
Bindingshould place the resulting expression in theFormatterContext.field(Field)out parameter. If the out parameter is left untouched, then no JSON specific formatting is applied to theFormatterContext.field()expression.The
FormatterContext.multiset()flag indicates that the JSON context is from aNestedCollectionEmulation.JSONemulation for aDSL.multiset(TableLike)expression. -
formatJSONB
Format theFormatterContext.field()expression to embed it in aSQLDataType.JSONBcontext.If applicable, a
Bindingshould place the resulting expression in theFormatterContext.field(Field)out parameter. If the out parameter is left untouched, then no JSONB specific formatting is applied to theFormatterContext.field()expression.The
FormatterContext.multiset()flag indicates that the JSONB context is from aNestedCollectionEmulation.JSONBemulation for aDSL.multiset(TableLike)expression. -
formatXML
Format theFormatterContext.field()expression to embed it in aSQLDataType.XMLcontext.If applicable, a
Bindingshould place the resulting expression in theFormatterContext.field(Field)out parameter. If the out parameter is left untouched, then no XML specific formatting is applied to theFormatterContext.field()expression.The
FormatterContext.multiset()flag indicates that the XML context is from aNestedCollectionEmulation.XMLemulation for aDSL.multiset(TableLike)expression.
-