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 008import com.avaje.ebean.Query; 009 010/** 011 * Specify the default cache use specific entity type. 012 */ 013@Target({ ElementType.TYPE }) 014@Retention(RetentionPolicy.RUNTIME) 015public @interface CacheStrategy { 016 017 /** 018 * When set to true the bean cache will be used unless explicitly stated not 019 * to in a query via {@link Query#setUseCache(boolean)}. 020 */ 021 boolean useBeanCache() default true; 022 023 /** 024 * A single property that is a natural unique identifier for the bean. 025 * <p> 026 * When a findUnique query is used with this property as the sole expression 027 * then there will be a lookup into the L2 natural key cache. 028 * </p> 029 */ 030 String naturalKey() default ""; 031 032 /** 033 * When set to true the beans returned from a query will default to be 034 * readOnly. 035 * <p> 036 * If the bean is readOnly and has no relationships then it may be sharable. 037 * </p> 038 * <p> 039 * If you try to modify a readOnly bean it will throw an 040 * IllegalStateException. 041 * </p> 042 */ 043 boolean readOnly() default false; 044 045 /** 046 * Specify a query that can be used to warm the cache. 047 * <p> 048 * All the beans fetched by this query will be loaded into the bean cache and 049 * the query itself will be loaded into the query cache. 050 * </p> 051 * <p> 052 * The warming query will typically be executed at startup time after a short 053 * delay (defaults to a 30 seconds delay). 054 * </p> 055 */ 056 String warmingQuery() default ""; 057 058}