diff --git a/jOOQ/src/main/java/org/jooq/Generator.java b/jOOQ/src/main/java/org/jooq/Generator.java index 6306f076ae..137bfb5608 100644 --- a/jOOQ/src/main/java/org/jooq/Generator.java +++ b/jOOQ/src/main/java/org/jooq/Generator.java @@ -43,6 +43,11 @@ import java.util.function.Function; /** * A generator can be used with {@link DataType#generatedAlwaysAs(Generator)} to * implement dynamic, client side computed columns. + *
+ * This API is part of a commercial only feature. To use this feature, please
+ * use the jOOQ Professional Edition or the jOOQ Enterprise Edition.
+ *
+ * @author Lukas Eder
*/
@FunctionalInterface
public interface Generator
+ * This API is part of a commercial only feature. To use this feature, please
+ * use the jOOQ Professional Edition or the jOOQ Enterprise Edition.
+ *
+ * @author Lukas Eder
*/
-public interface GeneratorContext extends Scope {}
+public interface GeneratorContext extends Scope {
+
+ /**
+ * The statement type in which the {@link Generator} is being invoked, or
+ *
+ * {@link Generator} implementations may choose to execute different logic based
+ * on the statement type. One example are {@link AuditProvider} fields, which
+ * can distinguish between audit information on inserted or updated records.
+ *
+ * This API is part of a commercial only feature. To use this feature, please
+ * use the jOOQ Professional Edition or the jOOQ Enterprise Edition.
+ *
+ * @author Lukas Eder
+ */
+public enum GeneratorStatementType {
+
+ /**
+ * The {@link Generator} is being invoked in an {@link Insert} context, or
+ * in a {@link Merge}'s
+ * This applies to {@link GenerationOption#STORED} only.
+ */
+ INSERT,
+
+ /**
+ * The {@link Generator} is being invoked in an {@link Update} context, or
+ * in an {@link Insert}'s
+ * This applies to {@link GenerationOption#STORED} only.
+ */
+ UPDATE,
+
+ /**
+ * The {@link Generator} is being invoked in a {@link Select} context, or an
+ * {@link Insert}'s, {@link Update}'s, or {@link Delete}'s
+ *
+ * This applies to {@link GenerationOption#VIRTUAL} only.
+ */
+ SELECT
+}
diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
index 862955ba6f..0b27c38620 100644
--- a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
+++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java
@@ -199,7 +199,7 @@ implements
@Override
public final Fieldnull when the statement type is unknown / not applicable.
+ */
+ @Nullable
+ GeneratorStatementType statementType();
+}
diff --git a/jOOQ/src/main/java/org/jooq/GeneratorStatementType.java b/jOOQ/src/main/java/org/jooq/GeneratorStatementType.java
new file mode 100644
index 0000000000..ba735e19b6
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/GeneratorStatementType.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import org.jooq.impl.QOM.GenerationOption;
+
+/**
+ * The statement type of a {@link GeneratorContext}.
+ * INSERT clause context.
+ * ON DUPLICATE KEY UPDATE clause,
+ * ON CONFLICT DO UPDATE clause context, or in a
+ * {@link Merge}'s UPDATE clause context.
+ * RETURNING clause context.
+ *