-
@Target({METHOD,CONSTRUCTOR,TYPE,PACKAGE}) @Retention(RUNTIME) @Documented @Inherited public @interface Require
Require a set ofSQLDialect
to be supported by any jOOQ statement in the scope of this annotation.This annotation can be used at the use-site of jOOQ API at any given scope
ElementType.PACKAGE
,ElementType.TYPE
,ElementType.METHOD
in order to specify that the given scope requires ALL of the suppliedSQLDialect
to be supported by all usage of jOOQ API within the scope. For example:// Allow only MYSQL or ORACLE dialect support to be used within the class scope @Allow(MYSQL, ORACLE) public class MySQLAndOracleDAO { // Allow rule from class applies to this method public void mysqlAndOracleMethod() { DSL.using(configuration) .insertInto(TABLE, TABLE.COLUMN) .values(1) // This type checks as it works on both MySQL and Oracle .onDuplicateKeyUpdate() .set(TABLE.COLUMN, 2) .execute(); } // Refine class Allow rule with additional requirement @Require(ORACLE) public void oracleOnlyMethod() { DSL.using(configuration) .mergeInto(TABLE) .using(selectOne()) .on(TABLE.COLUMN.eq(1)) .whenMatchedThenUpdate() .set(TABLE.COLUMN, 2) .whenNotMatchedThenInsert(TABLE.COLUMN) .values(1) .execute(); } }
Type checking for these annotations can be supplied by
org.jooq.checker.SQLDialectChecker
from the jOOQ-checker module.Type checking for these annotations can be supplied by
org.jooq.checker.SQLDialectChecker
from the jOOQ-checker module.Rules:
- In the absence of any
Allow
annotation, no jOOQ API usage is allowed. - The combination of all
Allow
annotations and of the inner-mostRequire
annotation is applied for any given scope. - Nested packages are not creating nested scopes.
- If a versioned
SQLDialect
is required (rather than aSQLDialect.family()
), then the required version, any of itsSQLDialect.predecessor()
, or itsSQLDialect.family()
are required.
- Author:
- Lukas Eder
- See Also:
Allow
- In the absence of any
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description SQLDialect[]
value
A list of jOOQSQLDialect
which are required on any jOOQ API method that is annotated withSupport
.
-
-
-
Element Detail
-
value
SQLDialect[] value
A list of jOOQSQLDialect
which are required on any jOOQ API method that is annotated withSupport
.- Default:
- {}
-
-