001package io.ebean.annotation;
002
003import java.lang.annotation.ElementType;
004import java.lang.annotation.Repeatable;
005import java.lang.annotation.Retention;
006import java.lang.annotation.RetentionPolicy;
007import java.lang.annotation.Target;
008
009/**
010 * Add an Literal to add to the where clause when a many property (List, Set or
011 * Map) is loaded or refreshed.
012 * <pre>{@code
013 *
014 * // on a OneToMany property...
015 *
016 * @OneToMany
017 * @Where(clause = "deleted='y'")
018 * List<Topic> topics;
019 *
020 * }</pre>
021 * <p>
022 * Note that you can include "${ta}" as a place holder for the table alias if
023 * you need to include the table alias in the clause.
024 * </p>
025 * <pre>{@code
026 * // ... including the ${ta} table alias placeholder...
027 *
028 * @OneToMany
029 * @Where(clause = "${ta}.deleted='y'")
030 * List<Topic> topics;
031 *
032 * }</pre>
033 * <p>
034 * This will be added to the where clause when lazy loading the OneToMany
035 * property or when there is a join to that OneToMany property.
036 * </p>
037 */
038@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
039@Retention(RetentionPolicy.RUNTIME)
040@Repeatable(Where.List.class)
041public @interface Where {
042
043  /**
044   * The clause added to the lazy load query.
045   * <p>
046   * Note that you can include "${ta}" as a place holder for the table alias if
047   * you need to include the table alias in the clause.
048   * </p>
049   */
050  String clause();
051
052  /**
053   * The platform where this annotation is active. Default: any platform
054   */
055  Platform[] platforms() default {};
056
057  /**
058   * Repeatable support for {@link Where}.
059   */
060  @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })
061  @Retention(RetentionPolicy.RUNTIME)
062  @interface List {
063
064    Where[] value() default {};
065  }
066}