Skip to content

nontrivial refactoring to ToOneBinder #10384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
ParamDef[] parameters() default {};

/**
* Specifies that the filter auto-enabled, so that it is
* Specifies that the filter is auto-enabled, so that it is
* not necessary to call
* {@link org.hibernate.Session#enableFilter(String)}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static void bindAny(
EntityBinder entityBinder,
boolean isIdentifierMapper,
MetadataBuildingContext context,
MemberDetails property,
AnnotatedJoinColumns joinColumns) {
final MemberDetails property = inferredData.getAttributeMember();

//check validity
if ( property.hasDirectAnnotationUsage( Columns.class ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ public static void bindCollection(
boolean isIdentifierMapper,
MetadataBuildingContext context,
Map<ClassDetails, InheritanceState> inheritanceStatePerClass,
MemberDetails property,
AnnotatedJoinColumns joinColumns) {
final ModelsContext modelsContext = context.getBootstrapContext().getModelsContext();
final MemberDetails property = inferredData.getAttributeMember();

final OneToMany oneToManyAnn = property.getAnnotationUsage( OneToMany.class, modelsContext );
final ManyToMany manyToManyAnn = property.getAnnotationUsage( ManyToMany.class, modelsContext );
final ElementCollection elementCollectionAnn = property.getAnnotationUsage( ElementCollection.class, modelsContext );
checkAnnotations( propertyHolder, inferredData, property, oneToManyAnn, manyToManyAnn, elementCollectionAnn );

final CollectionBinder collectionBinder = getCollectionBinder( property, hasMapKeyAnnotation( property ), context );
collectionBinder.setIndexColumn( getIndexColumn( propertyHolder, inferredData, entityBinder, context, property ) );
collectionBinder.setIndexColumn( getIndexColumn( propertyHolder, inferredData, entityBinder, context ) );
collectionBinder.setMapKey( property.getAnnotationUsage( MapKey.class, modelsContext ) );
collectionBinder.setPropertyName( inferredData.getPropertyName() );
collectionBinder.setJpaOrderBy( property.getAnnotationUsage( OrderBy.class, modelsContext ) );
Expand Down Expand Up @@ -423,8 +423,8 @@ private static IndexColumn getIndexColumn(
PropertyHolder propertyHolder,
PropertyData inferredData,
EntityBinder entityBinder,
MetadataBuildingContext context,
MemberDetails property) {
MetadataBuildingContext context) {
final MemberDetails property = inferredData.getAttributeMember();
return IndexColumn.fromAnnotations(
property.getDirectAnnotationUsage( OrderColumn.class ),
property.getDirectAnnotationUsage( ListIndexBase.class ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private ManyToOne createManyToOne(OneToOne oneToOne, Join mappedByJoin) {

private Property targetProperty(OneToOne oneToOne, PersistentClass targetEntity) {
try {
Property targetProperty = findPropertyByName( targetEntity, mappedBy );
final Property targetProperty = findPropertyByName( targetEntity, mappedBy );
if ( targetProperty != null ) {
return targetProperty;
}
Expand Down Expand Up @@ -272,13 +272,14 @@ private void bindOwned(
* the owning side.
*/
private Join buildJoinFromMappedBySide(PersistentClass persistentClass, Property otherSideProperty, Join originalJoin) {
Join join = new Join();
final Join join = new Join();
join.setPersistentClass( persistentClass );

//no check constraints available on joins
join.setTable( originalJoin.getTable() );
join.setInverse( true );
DependantValue key = new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );
final DependantValue key =
new DependantValue( buildingContext, join.getTable(), persistentClass.getIdentifier() );

if ( notFoundAction != null ) {
join.disableForeignKeyCreation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,7 @@ public static void processElementAnnotations(
isComponentEmbedded,
inSecondPass,
context,
inheritanceStatePerClass,
property
inheritanceStatePerClass
);
}
}
Expand Down Expand Up @@ -756,8 +755,9 @@ private static void buildProperty(
boolean isComponentEmbedded,
boolean inSecondPass,
MetadataBuildingContext context,
Map<ClassDetails, InheritanceState> inheritanceStatePerClass,
MemberDetails property) {
Map<ClassDetails, InheritanceState> inheritanceStatePerClass) {

final MemberDetails property = inferredData.getAttributeMember();

if ( isPropertyOfRegularEmbeddable( propertyHolder, isComponentEmbedded )
&& property.hasDirectAnnotationUsage(Id.class)) {
Expand All @@ -777,7 +777,6 @@ private static void buildProperty(
isIdentifierMapper,
context,
inheritanceStatePerClass,
property,
attributeTypeDetails
);

Expand All @@ -798,7 +797,6 @@ private static void buildProperty(
isIdentifierMapper,
isComponentEmbedded,
inSecondPass,
property,
attributeTypeDetails.determineRawClass(),
columnsBuilder
);
Expand All @@ -812,8 +810,8 @@ private static PropertyBinder propertyBinder(
boolean isIdentifierMapper,
MetadataBuildingContext context,
Map<ClassDetails, InheritanceState> inheritanceStatePerClass,
MemberDetails property,
TypeDetails attributeTypeDetails) {
final MemberDetails property = inferredData.getAttributeMember();
final PropertyBinder propertyBinder = new PropertyBinder();
propertyBinder.setName( inferredData.getPropertyName() );
propertyBinder.setReturnedClassName( inferredData.getTypeName() );
Expand Down Expand Up @@ -847,9 +845,9 @@ private AnnotatedColumns bindProperty(
boolean isIdentifierMapper,
boolean isComponentEmbedded,
boolean inSecondPass,
MemberDetails property,
ClassDetails returnedClass,
ColumnsBuilder columnsBuilder) {
final MemberDetails property = inferredData.getAttributeMember();
if ( isVersion( property ) ) {
bindVersionProperty(
propertyHolder,
Expand All @@ -865,7 +863,6 @@ else if ( isManyToOne( property ) ) {
isIdentifierMapper,
inSecondPass,
buildingContext,
property,
columnsBuilder.getJoinColumns(),
this
);
Expand All @@ -877,7 +874,6 @@ else if ( isOneToOne( property ) ) {
isIdentifierMapper,
inSecondPass,
buildingContext,
property,
columnsBuilder.getJoinColumns(),
this
);
Expand All @@ -890,7 +886,6 @@ else if ( isAny( property ) ) {
entityBinder,
isIdentifierMapper,
buildingContext,
property,
columnsBuilder.getJoinColumns()
);
}
Expand All @@ -903,7 +898,6 @@ else if ( isCollection( property ) ) {
isIdentifierMapper,
buildingContext,
inheritanceStatePerClass,
property,
columnsBuilder.getJoinColumns()
);
}
Expand All @@ -917,7 +911,6 @@ else if ( !isId() || !entityBinder.isIgnoreIdAnnotations() ) {
entityBinder,
isIdentifierMapper,
isComponentEmbedded,
property,
columnsBuilder,
columnsBuilder.getColumns(),
returnedClass
Expand Down Expand Up @@ -1002,10 +995,10 @@ private AnnotatedColumns bindBasicOrComposite(
EntityBinder entityBinder,
boolean isIdentifierMapper,
boolean isComponentEmbedded,
MemberDetails property,
ColumnsBuilder columnsBuilder,
AnnotatedColumns columns,
ClassDetails returnedClass) {
final MemberDetails property = inferredData.getAttributeMember();

// overrides from @MapsId or @IdClass if needed
final PropertyData overridingProperty =
Expand All @@ -1030,7 +1023,6 @@ private AnnotatedColumns bindBasicOrComposite(
isComposite,
isIdentifierMapper,
isComponentEmbedded,
property,
columns,
returnedClass,
actualColumns,
Expand Down Expand Up @@ -1075,7 +1067,6 @@ private PropertyBinder propertyBinder(
boolean isComposite,
boolean isIdentifierMapper,
boolean isComponentEmbedded,
MemberDetails property,
AnnotatedColumns columns,
ClassDetails returnedClass,
AnnotatedColumns actualColumns,
Expand All @@ -1084,6 +1075,7 @@ private PropertyBinder propertyBinder(
final Class<? extends CompositeUserType<?>> compositeUserType =
resolveCompositeUserType( inferredData, buildingContext );

final MemberDetails property = inferredData.getAttributeMember();
if ( isComposite || compositeUserType != null ) {
if ( property.isArray() && property.getElementType() != null
&& isEmbedded( property, property.getElementType() ) ) {
Expand Down
Loading