mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 16:47:18 +00:00
#1456 - io.ebean.annotation.NotNull not honored by @ManyToOne property
This commit is contained in:
@@ -246,6 +246,9 @@ public class PlatformDdl {
|
||||
* Convert the standard type to the platform specific type.
|
||||
*/
|
||||
public String convert(String type, boolean identity) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
if (type.contains("[]")) {
|
||||
return convertArrayType(type);
|
||||
}
|
||||
|
||||
@@ -116,6 +116,10 @@ public class AnnotationAssocOnes extends AnnotationParser {
|
||||
prop.setFetchPreference(fetchPreference.value());
|
||||
}
|
||||
|
||||
io.ebean.annotation.NotNull nonNull = get(prop, io.ebean.annotation.NotNull.class);
|
||||
if (nonNull != null) {
|
||||
prop.setNullable(false);
|
||||
}
|
||||
if (validationAnnotations) {
|
||||
NotNull notNull = get(prop, NotNull.class);
|
||||
if (notNull != null && isEbeanValidationGroups(notNull.groups())) {
|
||||
|
||||
@@ -108,7 +108,6 @@ public class EBasic {
|
||||
@DbDefault("42")
|
||||
int newInteger;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
@DbMigration(preAlter= "insert into migtest_e_user (id) select distinct user_id from migtest_e_basic") // ensure all users exist
|
||||
EUser user;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.tests.merge;
|
||||
|
||||
import io.ebean.annotation.NotNull;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@@ -12,7 +14,8 @@ public class MContactMessage extends MBase {
|
||||
|
||||
private String notes;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
private MContact contact;
|
||||
|
||||
public MContactMessage(String title, String subject) {
|
||||
|
||||
Reference in New Issue
Block a user