-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-18724 Take constraint composition type into account when determin…
…ing nullable state of a Column
- Loading branch information
1 parent
d702496
commit bafc6a8
Showing
5 changed files
with
167 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/NullAndNotBlank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hibernate.orm.test.annotations.beanvalidation; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
import jakarta.validation.ReportAsSingleViolation; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Null; | ||
import org.hibernate.validator.constraints.ConstraintComposition; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
import static org.hibernate.validator.constraints.CompositionType.AND; | ||
|
||
/** | ||
* Used to test constraint composition with AND for nullability of columns. | ||
*/ | ||
@ConstraintComposition(AND) | ||
@Null | ||
@NotBlank | ||
@ReportAsSingleViolation | ||
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Constraint(validatedBy = {}) | ||
public @interface NullAndNotBlank { | ||
|
||
String message() default "{org.hibernate.validator.constraints.NullAndNotBlank.message}"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...-core/src/test/java/org/hibernate/orm/test/annotations/beanvalidation/NullOrNotBlank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hibernate.orm.test.annotations.beanvalidation; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
import jakarta.validation.ReportAsSingleViolation; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Null; | ||
import org.hibernate.validator.constraints.ConstraintComposition; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
import static org.hibernate.validator.constraints.CompositionType.OR; | ||
|
||
/** | ||
* Used to test constraint composition with OR for nullability of columns. | ||
*/ | ||
@ConstraintComposition(OR) | ||
@Null | ||
@NotBlank | ||
@ReportAsSingleViolation | ||
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) | ||
@Retention(RUNTIME) | ||
@Documented | ||
@Constraint(validatedBy = {}) | ||
public @interface NullOrNotBlank { | ||
|
||
String message() default "{org.hibernate.validator.constraints.NullOrNotBlank.message}"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
} |