|
14 | 14 | import java.util.Locale; |
15 | 15 | import java.util.Map; |
16 | 16 | import java.util.Set; |
17 | | -import java.util.StringTokenizer; |
18 | 17 |
|
19 | 18 | import jakarta.validation.NoProviderFoundException; |
20 | 19 | import jakarta.validation.constraints.Digits; |
|
25 | 24 | import jakarta.validation.constraints.NotNull; |
26 | 25 | import jakarta.validation.constraints.Size; |
27 | 26 | import org.hibernate.AssertionFailure; |
28 | | -import org.hibernate.MappingException; |
29 | 27 | import org.hibernate.boot.internal.ClassLoaderAccessImpl; |
30 | 28 | import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; |
31 | 29 | import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; |
|
60 | 58 | import static java.util.Collections.disjoint; |
61 | 59 | import static org.hibernate.boot.beanvalidation.BeanValidationIntegrator.APPLY_CONSTRAINTS; |
62 | 60 | import static org.hibernate.boot.beanvalidation.GroupsPerOperation.buildGroupsForOperation; |
| 61 | +import static org.hibernate.boot.model.internal.BinderHelper.findPropertyByName; |
63 | 62 | import static org.hibernate.cfg.ValidationSettings.CHECK_NULLABILITY; |
64 | 63 | import static org.hibernate.cfg.ValidationSettings.JAKARTA_VALIDATION_FACTORY; |
65 | 64 | import static org.hibernate.cfg.ValidationSettings.JPA_VALIDATION_FACTORY; |
66 | | -import static org.hibernate.internal.util.StringHelper.isEmpty; |
67 | 65 | import static org.hibernate.internal.util.StringHelper.isNotEmpty; |
68 | 66 |
|
69 | 67 | /** |
@@ -496,72 +494,6 @@ private static boolean isValidatorLengthAnnotation(ConstraintDescriptor<?> descr |
496 | 494 | .equals( descriptor.getAnnotation().annotationType().getName() ); |
497 | 495 | } |
498 | 496 |
|
499 | | - /** |
500 | | - * Locate the property by path in a recursive way, including IdentifierProperty in the loop if propertyName is |
501 | | - * {@code null}. If propertyName is {@code null} or empty, the IdentifierProperty is returned |
502 | | - */ |
503 | | - private static Property findPropertyByName(PersistentClass associatedClass, String propertyName) { |
504 | | - Property property = null; |
505 | | - final Property idProperty = associatedClass.getIdentifierProperty(); |
506 | | - final String idName = idProperty != null ? idProperty.getName() : null; |
507 | | - try { |
508 | | - if ( isEmpty( propertyName ) || propertyName.equals( idName ) ) { |
509 | | - //default to id |
510 | | - property = idProperty; |
511 | | - } |
512 | | - else { |
513 | | - if ( propertyName.indexOf( idName + "." ) == 0 ) { |
514 | | - property = idProperty; |
515 | | - propertyName = propertyName.substring( idName.length() + 1 ); |
516 | | - } |
517 | | - final StringTokenizer tokens = new StringTokenizer( propertyName, ".", false ); |
518 | | - while ( tokens.hasMoreTokens() ) { |
519 | | - final String element = tokens.nextToken(); |
520 | | - if ( property == null ) { |
521 | | - property = associatedClass.getProperty( element ); |
522 | | - } |
523 | | - else { |
524 | | - if ( property.isComposite() ) { |
525 | | - property = ( (Component) property.getValue() ).getProperty( element ); |
526 | | - } |
527 | | - else { |
528 | | - return null; |
529 | | - } |
530 | | - } |
531 | | - } |
532 | | - } |
533 | | - } |
534 | | - catch ( MappingException e ) { |
535 | | - try { |
536 | | - //if we do not find it, try to check the identifier mapper |
537 | | - if ( associatedClass.getIdentifierMapper() == null ) { |
538 | | - return null; |
539 | | - } |
540 | | - else { |
541 | | - final StringTokenizer tokens = new StringTokenizer( propertyName, ".", false ); |
542 | | - while ( tokens.hasMoreTokens() ) { |
543 | | - final String element = tokens.nextToken(); |
544 | | - if ( property == null ) { |
545 | | - property = associatedClass.getIdentifierMapper().getProperty( element ); |
546 | | - } |
547 | | - else { |
548 | | - if ( property.isComposite() ) { |
549 | | - property = ( (Component) property.getValue() ).getProperty( element ); |
550 | | - } |
551 | | - else { |
552 | | - return null; |
553 | | - } |
554 | | - } |
555 | | - } |
556 | | - } |
557 | | - } |
558 | | - catch ( MappingException ee ) { |
559 | | - return null; |
560 | | - } |
561 | | - } |
562 | | - return property; |
563 | | - } |
564 | | - |
565 | 497 | private static ValidatorFactory getValidatorFactory(ActivationContext context) { |
566 | 498 | // IMPL NOTE: We can either be provided a ValidatorFactory or make one. We can be provided |
567 | 499 | // a ValidatorFactory in 2 different ways. So here we "get" a ValidatorFactory |
|
0 commit comments