Class BinderHelper
- java.lang.Object
-
- org.hibernate.boot.model.internal.BinderHelper
-
public class BinderHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static Set<String>PRIMITIVE_NAMES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AnybuildAnyValue(jakarta.persistence.Column discriminatorColumn, Formula discriminatorFormula, AnnotatedJoinColumns keyColumns, PropertyData inferredData, OnDeleteAction onDeleteAction, boolean lazy, Nullability nullability, PropertyHolder propertyHolder, EntityBinder entityBinder, boolean optional, MetadataBuildingContext context)static voidcreateSyntheticPropertyReference(AnnotatedJoinColumns joinColumns, PersistentClass targetEntity, PersistentClass associatedEntity, Value value, String propertyName, boolean inverse, MetadataBuildingContext context)Here we address a fundamental problem: the@JoinColumnannotation specifies the referenced column in the target table viareferencedColumnName, 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.static ObjectfindColumnOwner(PersistentClass persistentClass, String columnName, MetadataBuildingContext context)Find the column owner (ie PersistentClass or Join) of columnName.static PropertyfindPropertyByName(Component component, String propertyName)Retrieve the property by path in a recursive waystatic PropertyfindPropertyByName(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 returnedstatic ObjectfindReferencedColumnOwner(PersistentClass persistentClass, AnnotatedJoinColumn joinColumn, MetadataBuildingContext context)static StringgetCascadeStrategy(jakarta.persistence.CascadeType[] ejbCascades, Cascade hibernateCascadeAnnotation, boolean orphanRemoval, boolean forcePersist)static FetchModegetFetchMode(jakarta.persistence.FetchType fetch)static MappedSuperclassgetMappedSuperclassOrNull(org.hibernate.annotations.common.reflection.XClass declaringClass, Map<org.hibernate.annotations.common.reflection.XClass,InheritanceState> inheritanceStatePerClass, MetadataBuildingContext context)static <T extends Annotation>
TgetOverridableAnnotation(org.hibernate.annotations.common.reflection.XAnnotatedElement element, Class<T> annotationType, MetadataBuildingContext context)static StringgetPath(PropertyHolder holder, PropertyData property)static StringgetRelativePath(PropertyHolder propertyHolder, String propertyName)static booleanhasToOneAnnotation(org.hibernate.annotations.common.reflection.XAnnotatedElement property)static booleanisPrimitive(String elementTypeName)static voidmakeIdGenerator(SimpleValue id, org.hibernate.annotations.common.reflection.XProperty property, String generatorType, String generatorName, MetadataBuildingContext buildingContext, Map<String,IdentifierGeneratorDefinition> localGenerators)Apply an id generation strategy and parameters to the givenSimpleValuewhich represents an identifier.static voidmakeIdGenerator(SimpleValue id, org.hibernate.annotations.common.reflection.XProperty idXProperty, String generatorType, String generatorName, MetadataBuildingContext buildingContext, IdentifierGeneratorDefinition foreignKGeneratorDefinition)apply an id generator to a SimpleValuestatic PropertyshallowCopy(Property property)static Map<String,String>toAliasEntityMap(SqlFragmentAlias[] aliases)static Map<String,String>toAliasTableMap(SqlFragmentAlias[] aliases)
-
-
-
Method Detail
-
isPrimitive
public static boolean isPrimitive(String elementTypeName)
-
createSyntheticPropertyReference
public static void createSyntheticPropertyReference(AnnotatedJoinColumns joinColumns, PersistentClass targetEntity, PersistentClass associatedEntity, Value value, String propertyName, boolean inverse, MetadataBuildingContext context)
Here we address a fundamental problem: the@JoinColumnannotation specifies the referenced column in the target table viareferencedColumnName, 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"
Componentin the model that aggregates these properties and is considered the target of the association.
@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 syntheticComponent.
-
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
-
getRelativePath
public static String getRelativePath(PropertyHolder propertyHolder, String propertyName)
-
findReferencedColumnOwner
public static Object findReferencedColumnOwner(PersistentClass persistentClass, AnnotatedJoinColumn joinColumn, MetadataBuildingContext context)
-
findColumnOwner
public static Object findColumnOwner(PersistentClass persistentClass, String columnName, MetadataBuildingContext context)
Find the column owner (ie PersistentClass or Join) of columnName. If columnName is null or empty, persistentClass is returned
-
makeIdGenerator
public static void makeIdGenerator(SimpleValue id, org.hibernate.annotations.common.reflection.XProperty property, String generatorType, String generatorName, MetadataBuildingContext buildingContext, Map<String,IdentifierGeneratorDefinition> localGenerators)
Apply an id generation strategy and parameters to the givenSimpleValuewhich represents an identifier.
-
makeIdGenerator
public static void makeIdGenerator(SimpleValue id, org.hibernate.annotations.common.reflection.XProperty idXProperty, String generatorType, String generatorName, MetadataBuildingContext buildingContext, IdentifierGeneratorDefinition foreignKGeneratorDefinition)
apply an id generator to a SimpleValue
-
buildAnyValue
public static Any buildAnyValue(jakarta.persistence.Column discriminatorColumn, Formula discriminatorFormula, AnnotatedJoinColumns keyColumns, PropertyData inferredData, OnDeleteAction onDeleteAction, boolean lazy, Nullability nullability, PropertyHolder propertyHolder, EntityBinder entityBinder, boolean optional, MetadataBuildingContext context)
-
getMappedSuperclassOrNull
public static MappedSuperclass getMappedSuperclassOrNull(org.hibernate.annotations.common.reflection.XClass declaringClass, Map<org.hibernate.annotations.common.reflection.XClass,InheritanceState> inheritanceStatePerClass, MetadataBuildingContext context)
-
getPath
public static String getPath(PropertyHolder holder, PropertyData property)
-
toAliasTableMap
public static Map<String,String> toAliasTableMap(SqlFragmentAlias[] aliases)
-
toAliasEntityMap
public static Map<String,String> toAliasEntityMap(SqlFragmentAlias[] aliases)
-
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)
-
getFetchMode
public static FetchMode getFetchMode(jakarta.persistence.FetchType fetch)
-
-