Class BinderHelper


  • public class BinderHelper
    extends Object
    • Field Detail

      • PRIMITIVE_NAMES

        public static final Set<String> PRIMITIVE_NAMES
    • Method Detail

      • shallowCopy

        public static Property shallowCopy​(Property property)
        create a property copy reusing the same value
      • createSyntheticPropertyReference

        public static void createSyntheticPropertyReference​(AnnotatedJoinColumn[] columns,
                                                            PersistentClass ownerEntity,
                                                            PersistentClass associatedEntity,
                                                            Value value,
                                                            boolean inverse,
                                                            MetadataBuildingContext context)
        Here we address a fundamental problem: the @JoinColumn annotation specifies the referenced column in the target table via referencedColumnName, but Hibernate needs to know which property or field of the target entity class holds the value of the referenced column at the Java level. (It's going to need the value when it writes the association.)

        Complicating this hugely is the fact that an association might be based on a composite key with multiple @JoinColumns, and so the referenced columns might even be spread out over multiple fields or properties of the target entity. There's even some extra minor complications resulting from multi-table inheritance and secondary tables.

        The solution here is:

        • if the referenced columns correspond to exactly one property of the target entity, we're good, just use it, or
        • otherwise, if a composite key is spread out over multiple properties, then create a "synthetic" Component in the model that aggregates these properties and is considered the target of the association.
        Certain limitations arise from the way this solution is currently implemented: for example, if a referenced column belongs to a property of an @Embeddable, then every column of that embeddable must occur in the list of referenced columns, and the order of the columns must line up! Some of these limitations could be relaxed using by writing a better algorithm for building the synthetic Component.
      • findPropertyByName

        public static Property findPropertyByName​(PersistentClass associatedClass,
                                                  String propertyName)
        Retrieve the property by path in a recursive way, including IdentifierProperty in the loop If propertyName is null or empty, the IdentifierProperty is returned
      • findPropertyByName

        public static Property findPropertyByName​(Component component,
                                                  String propertyName)
        Retrieve the property by path in a recursive way
      • isEmptyAnnotationValue

        public static boolean isEmptyAnnotationValue​(String annotationString)
      • isEmptyOrNullAnnotationValue

        public static boolean isEmptyOrNullAnnotationValue​(String annotationString)
      • getAnnotationValueStringOrNull

        public static String getAnnotationValueStringOrNull​(String value)
      • getMappedSuperclassOrNull

        public static MappedSuperclass getMappedSuperclassOrNull​(org.hibernate.annotations.common.reflection.XClass declaringClass,
                                                                 Map<org.hibernate.annotations.common.reflection.XClass,​InheritanceState> inheritanceStatePerClass,
                                                                 MetadataBuildingContext context)
      • hasToOneAnnotation

        public static boolean hasToOneAnnotation​(org.hibernate.annotations.common.reflection.XAnnotatedElement property)
      • getOverridableAnnotation

        public static <T extends Annotation> T getOverridableAnnotation​(org.hibernate.annotations.common.reflection.XAnnotatedElement element,
                                                                        Class<T> annotationType,
                                                                        MetadataBuildingContext context)