use of javax.validation.metadata.ConstraintDescriptor in project hibernate-orm by hibernate.
the class TypeSafeActivator method applyMin.
private static void applyMin(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) {
if (Min.class.equals(descriptor.getAnnotation().annotationType())) {
@SuppressWarnings("unchecked") ConstraintDescriptor<Min> minConstraint = (ConstraintDescriptor<Min>) descriptor;
long min = minConstraint.getAnnotation().value();
@SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator();
if (itor.hasNext()) {
final Selectable selectable = itor.next();
if (Column.class.isInstance(selectable)) {
Column col = (Column) selectable;
String checkConstraint = col.getQuotedName(dialect) + ">=" + min;
applySQLCheck(col, checkConstraint);
}
}
}
}
use of javax.validation.metadata.ConstraintDescriptor in project hibernate-orm by hibernate.
the class TypeSafeActivator method applyMax.
private static void applyMax(Property property, ConstraintDescriptor<?> descriptor, Dialect dialect) {
if (Max.class.equals(descriptor.getAnnotation().annotationType())) {
@SuppressWarnings("unchecked") ConstraintDescriptor<Max> maxConstraint = (ConstraintDescriptor<Max>) descriptor;
long max = maxConstraint.getAnnotation().value();
@SuppressWarnings("unchecked") final Iterator<Selectable> itor = property.getColumnIterator();
if (itor.hasNext()) {
final Selectable selectable = itor.next();
if (Column.class.isInstance(selectable)) {
Column col = (Column) selectable;
String checkConstraint = col.getQuotedName(dialect) + "<=" + max;
applySQLCheck(col, checkConstraint);
}
}
}
}
Aggregations