001package io.ebean.event; 002 003import io.ebean.config.DatabaseConfig; 004 005/** 006 * Objects extending this modify queries prior their execution. 007 * <p> 008 * This can be used to add expressions to a query - for example to enable 009 * partitioning based on the user executing the query. 010 * </p> 011 * <p> 012 * A BeanQueryAdapter is either found automatically via class path search or can 013 * be added programmatically via {@link DatabaseConfig#add(BeanQueryAdapter)}. 014 * </p> 015 * <p> 016 * Note that a BeanQueryAdapter should be thread safe (stateless) and if 017 * registered automatically via class path search it needs to have a default 018 * constructor. 019 * </p> 020 */ 021public interface BeanQueryAdapter { 022 023 /** 024 * Return true if this adapter is interested in queries for the given entity 025 * type. 026 */ 027 boolean isRegisterFor(Class<?> cls); 028 029 /** 030 * Returns an int to to control the order in which BeanQueryAdapter are 031 * executed when there is multiple of them registered for a given entity type 032 * (class). 033 */ 034 int getExecutionOrder(); 035 036 /** 037 * Modify the associated query prior to it being executed. 038 */ 039 void preQuery(BeanQueryRequest<?> request); 040 041}