001package com.avaje.ebean.annotation;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Retention;
005import java.lang.annotation.RetentionPolicy;
006import java.lang.annotation.Target;
007
008/**
009 * Specify a property holding JSON content.
010 * <p>
011 * By default the content will be stored in a DB Clob except on Postgres where DB JSON type is used.
012 * </p>
013 * <h3>Example:</h3>
014 * <pre>{@code
015 *
016 * // Store as JSON on Postgres or Clob on other databases
017 * @DbJson
018 * Map<String,Object> content;
019 *
020 * }</pre>
021 *
022 * <h3>Example with JSONB storage</h3>
023 * <pre>{@code
024 *
025 * // Store as JSONB on Postgres or Clob on other databases
026 * @DbJson(storage = DbJsonType.JSONB)
027 * Map<String,Object> content;
028 *
029 * }</pre>
030 */
031@Retention(RetentionPolicy.RUNTIME)
032@Target(ElementType.FIELD)
033public @interface DbJson {
034
035  /**
036   * Specify the database type used to store the JSON content.
037   */
038  DbJsonType storage() default DbJsonType.JSON;
039
040  /**
041   * For VARCHAR storage specify the column length (defaults to 3000).
042   */
043  int length() default 0;
044}