diff --git a/src/main/java/io/ebean/config/ServerConfig.java b/src/main/java/io/ebean/config/ServerConfig.java
index 29ac1032d..28211d1a5 100644
--- a/src/main/java/io/ebean/config/ServerConfig.java
+++ b/src/main/java/io/ebean/config/ServerConfig.java
@@ -470,6 +470,14 @@ public class ServerConfig {
*/
private boolean disableL2Cache;
+
+ /**
+ * Should the javax.validation.constraints.NotNull enforce a notNull column in DB.
+ * If set to false, you have to use io.ebean.annotation.NotNull to explicityl create
+ * a not null column.
+ */
+ private boolean useJavaxValidationNotNull = true;
+
/**
* Generally we want to perform L2 cache notification in the background and not impact
* the performance of executing transactions.
@@ -2740,6 +2748,7 @@ public class ServerConfig {
explicitTransactionBeginMode = p.getBoolean("explicitTransactionBeginMode", explicitTransactionBeginMode);
autoCommitMode = p.getBoolean("autoCommitMode", autoCommitMode);
useJtaTransactionManager = p.getBoolean("useJtaTransactionManager", useJtaTransactionManager);
+ useJavaxValidationNotNull = p.getBoolean("useJavaxValidationNotNull", useJavaxValidationNotNull);
autoReadOnlyDataSource = p.getBoolean("autoReadOnlyDataSource", autoReadOnlyDataSource);
backgroundExecutorSchedulePoolSize = p.getInt("backgroundExecutorSchedulePoolSize", backgroundExecutorSchedulePoolSize);
@@ -2959,6 +2968,27 @@ public class ServerConfig {
this.disableL2Cache = disableL2Cache;
}
+ /**
+ * Returns if we use javax.validation.constraints.NotNull
+ */
+ public boolean isUseJavaxValidationNotNull() {
+ return useJavaxValidationNotNull;
+ }
+
+ /**
+ * Controlws when Ebean should generate a NOT NULL column.
+ * If an io.ebean.annotation.NotNull is present, Ebean generates
+ * NOT NULL columns
+ * If set to true (default) Ebean generates also
+ * NOT NULL columns when a &x64;javax.validation.contstraints.NotNull
+ * annotation is present (and it is in Default group.)
+ * If set to false the &x64;javax.validation.contstraints.NotNull is
+ * ignored
+ */
+ public void setUseJavaxValidationNotNull(boolean useJavaxValidationNotNull) {
+ this.useJavaxValidationNotNull = useJavaxValidationNotNull;
+ }
+
/**
* Return true if L2 cache notification should run in the foreground.
*/
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java
index bab69310c..838f9308d 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationParser.java
@@ -97,6 +97,9 @@ public abstract class AnnotationParser extends AnnotationBase {
* can be applied to DDL generation.
*/
protected boolean isEbeanValidationGroups(Class>[] groups) {
+ if (!util.isUseJavaxValidationNotNull()) {
+ return false;
+ }
if (groups.length == 0
|| groups.length == 1 && javax.validation.groups.Default.class.isAssignableFrom(groups[0])) {
return true;
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
index b821cb89a..ccb44db9d 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
@@ -60,6 +60,8 @@ public class DeployUtil {
private final Encryptor bytesEncryptor;
+ private final boolean useJavaxValidationNotNull;
+
public DeployUtil(TypeManager typeMgr, ServerConfig serverConfig) {
this.typeManager = typeMgr;
@@ -70,6 +72,7 @@ public class DeployUtil {
Encryptor be = serverConfig.getEncryptor();
this.bytesEncryptor = be != null ? be : new SimpleAesEncryptor();
+ this.useJavaxValidationNotNull = serverConfig.isUseJavaxValidationNotNull();
}
public TypeManager getTypeManager() {
@@ -294,4 +297,7 @@ public class DeployUtil {
return type.equals(String.class);
}
+ public boolean isUseJavaxValidationNotNull() {
+ return useJavaxValidationNotNull;
+ }
}