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 collection property that will be stored into a DB ARRAY type. 010 * <p> 011 * If the target database does not support ARRAY type (so not Postgres) 012 * then the collection will be stored in JSON format into a VARCHAR column. 013 * </p> 014 * 015 * <h3>Example:</h3> 016 * <pre>{@code 017 * 018 * // Store as ARRAY of UUID on Postgres 019 * @DbArray 020 * List<UUID> uids = new ArrayList<>(); 021 * 022 * // Store as ARRAY on Postgres 023 * @DbArray 024 * List<String> phoneNumbers = new ArrayList<>(); 025 * 026 * // Store as ARRAY of INTEGER on Postgres 027 * @DbArray 028 * List<Long> someLongs = new ArrayList<>(); 029 * 030 * }</pre> 031 */ 032@Retention(RetentionPolicy.RUNTIME) 033@Target(ElementType.FIELD) 034public @interface DbArray { 035 036 /** 037 * For VARCHAR storage specify the column length (defaults to 1000). 038 */ 039 int length() default 0; 040}