Annotation Interface JsonViewGenerated


@Retention(RUNTIME) @Target({FIELD,METHOD,RECORD_COMPONENT}) @Documented public @interface JsonViewGenerated
Marks a property of a JsonView or JsonSubView as a generated field.

A generated field is computed by the database when the document is read and is not mapped to a column. Values sent for a generated field on insert or update are ignored. Exactly one of path() or sql() must be set.


@JsonView(entity = Product.class, hidden = {"price", "quantity"})
public record ProductView(
    @Id Long id,
    String name,
    @JsonViewGenerated(path = "$.price * $.quantity") Double total
) {}

Currently supported only by Oracle Database, in releases that support generated fields in duality views.

Since:
5.3
Author:
graemerocher
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    A SQL/JSON path expression evaluated against the document, for example $.price * $.quantity.
    A SQL expression evaluated against the table of the view, for example UPPER(@.name).
  • Element Details

    • path

      String path
      A SQL/JSON path expression evaluated against the document, for example $.price * $.quantity. It can reference hidden fields.
      Returns:
      the path expression
      Default:
      ""
    • sql

      String sql
      A SQL expression evaluated against the table of the view, for example UPPER(@.name). Use the @. prefix to refer to columns of the table, it is replaced with the table alias.
      Returns:
      the SQL expression
      Default:
      ""