mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-18410 Hoist some state to AbstractAttributeMapping to avoid megamorphic call sites
This commit is contained in:
parent
e4bc19b64a
commit
0d58a2410c
@ -7,9 +7,11 @@
|
||||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.AttributeMetadata;
|
||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
/**
|
||||
@ -18,20 +20,39 @@
|
||||
public abstract class AbstractAttributeMapping implements AttributeMapping {
|
||||
private final String name;
|
||||
private final int fetchableIndex;
|
||||
private final int stateArrayPosition;
|
||||
|
||||
private final ManagedMappingType declaringType;
|
||||
private final AttributeMetadata attributeMetadata;
|
||||
private final PropertyAccess propertyAccess;
|
||||
|
||||
public AbstractAttributeMapping(String name, int fetchableIndex, ManagedMappingType declaringType) {
|
||||
public AbstractAttributeMapping(
|
||||
String name,
|
||||
int fetchableIndex,
|
||||
ManagedMappingType declaringType,
|
||||
AttributeMetadata attributeMetadata,
|
||||
int stateArrayPosition,
|
||||
PropertyAccess propertyAccess) {
|
||||
this.name = name;
|
||||
this.fetchableIndex = fetchableIndex;
|
||||
this.declaringType = declaringType;
|
||||
this.attributeMetadata = attributeMetadata;
|
||||
this.stateArrayPosition = stateArrayPosition;
|
||||
this.propertyAccess = propertyAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate Reactive
|
||||
*/
|
||||
protected AbstractAttributeMapping(AbstractAttributeMapping original) {
|
||||
this( original.name, original.fetchableIndex, original.declaringType );
|
||||
this(
|
||||
original.name,
|
||||
original.fetchableIndex,
|
||||
original.declaringType,
|
||||
original.attributeMetadata,
|
||||
original.stateArrayPosition,
|
||||
original.propertyAccess
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,6 +65,21 @@ public String getAttributeName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeMetadata getAttributeMetadata() {
|
||||
return attributeMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStateArrayPosition() {
|
||||
return stateArrayPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyAccess getPropertyAccess() {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFetchableKey() {
|
||||
return fetchableIndex;
|
||||
|
@ -26,8 +26,6 @@ public abstract class AbstractSingularAttributeMapping
|
||||
extends AbstractStateArrayContributorMapping
|
||||
implements SingularAttributeMapping {
|
||||
|
||||
private final PropertyAccess propertyAccess;
|
||||
|
||||
public AbstractSingularAttributeMapping(
|
||||
String name,
|
||||
int stateArrayPosition,
|
||||
@ -36,8 +34,7 @@ public AbstractSingularAttributeMapping(
|
||||
FetchOptions mappedFetchOptions,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( name, attributeMetadata, mappedFetchOptions, stateArrayPosition, fetchableIndex, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
super( name, attributeMetadata, mappedFetchOptions, stateArrayPosition, fetchableIndex, declaringType, propertyAccess );
|
||||
}
|
||||
|
||||
public AbstractSingularAttributeMapping(
|
||||
@ -49,8 +46,7 @@ public AbstractSingularAttributeMapping(
|
||||
FetchStyle fetchStyle,
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( name, attributeMetadata, fetchTiming, fetchStyle, stateArrayPosition, fetchableIndex, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
super( name, attributeMetadata, fetchTiming, fetchStyle, stateArrayPosition, fetchableIndex, declaringType, propertyAccess );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,12 +54,6 @@ public AbstractSingularAttributeMapping(
|
||||
*/
|
||||
protected AbstractSingularAttributeMapping( AbstractSingularAttributeMapping original ) {
|
||||
super( original );
|
||||
this.propertyAccess = original.propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyAccess getPropertyAccess() {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.AttributeMetadata;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.sql.results.graph.FetchOptions;
|
||||
|
||||
/**
|
||||
@ -19,10 +20,8 @@ public abstract class AbstractStateArrayContributorMapping
|
||||
extends AbstractAttributeMapping
|
||||
implements FetchOptions {
|
||||
|
||||
private final AttributeMetadata attributeMetadata;
|
||||
private final FetchTiming fetchTiming;
|
||||
private final FetchStyle fetchStyle;
|
||||
private final int stateArrayPosition;
|
||||
|
||||
public AbstractStateArrayContributorMapping(
|
||||
String name,
|
||||
@ -31,12 +30,11 @@ public AbstractStateArrayContributorMapping(
|
||||
FetchStyle fetchStyle,
|
||||
int stateArrayPosition,
|
||||
int fetchableIndex,
|
||||
ManagedMappingType declaringType) {
|
||||
super( name, fetchableIndex, declaringType );
|
||||
this.attributeMetadata = attributeMetadata;
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
super( name, fetchableIndex, declaringType, attributeMetadata, stateArrayPosition, propertyAccess );
|
||||
this.fetchTiming = fetchTiming;
|
||||
this.fetchStyle = fetchStyle;
|
||||
this.stateArrayPosition = stateArrayPosition;
|
||||
}
|
||||
|
||||
public AbstractStateArrayContributorMapping(
|
||||
@ -45,7 +43,8 @@ public AbstractStateArrayContributorMapping(
|
||||
FetchOptions mappedFetchOptions,
|
||||
int stateArrayPosition,
|
||||
int fetchableIndex,
|
||||
ManagedMappingType declaringType) {
|
||||
ManagedMappingType declaringType,
|
||||
PropertyAccess propertyAccess) {
|
||||
this(
|
||||
name,
|
||||
attributeMetadata,
|
||||
@ -53,7 +52,8 @@ public AbstractStateArrayContributorMapping(
|
||||
mappedFetchOptions.getStyle(),
|
||||
stateArrayPosition,
|
||||
fetchableIndex,
|
||||
declaringType
|
||||
declaringType,
|
||||
propertyAccess
|
||||
);
|
||||
}
|
||||
|
||||
@ -62,21 +62,8 @@ public AbstractStateArrayContributorMapping(
|
||||
*/
|
||||
protected AbstractStateArrayContributorMapping(AbstractStateArrayContributorMapping original) {
|
||||
super( original );
|
||||
this.attributeMetadata = original.attributeMetadata;
|
||||
this.fetchTiming = original.fetchTiming;
|
||||
this.fetchStyle = original.fetchStyle;
|
||||
this.stateArrayPosition = original.stateArrayPosition;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getStateArrayPosition() {
|
||||
return stateArrayPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeMetadata getAttributeMetadata() {
|
||||
return attributeMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,9 +95,6 @@ public interface Aware {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final CollectionMappingType collectionMappingType;
|
||||
private final int stateArrayPosition;
|
||||
private final PropertyAccess propertyAccess;
|
||||
private final AttributeMetadata attributeMetadata;
|
||||
private final String referencedPropertyName;
|
||||
private final String mapKeyPropertyName;
|
||||
|
||||
@ -137,11 +134,8 @@ public PluralAttributeMappingImpl(
|
||||
CascadeStyle cascadeStyle,
|
||||
ManagedMappingType declaringType,
|
||||
CollectionPersister collectionDescriptor) {
|
||||
super( attributeName, fetchableIndex, declaringType );
|
||||
this.propertyAccess = propertyAccess;
|
||||
this.attributeMetadata = attributeMetadata;
|
||||
super( attributeName, fetchableIndex, declaringType, attributeMetadata, stateArrayPosition, propertyAccess );
|
||||
this.collectionMappingType = collectionMappingType;
|
||||
this.stateArrayPosition = stateArrayPosition;
|
||||
this.elementDescriptor = elementDescriptor;
|
||||
this.indexDescriptor = indexDescriptor;
|
||||
this.identifierDescriptor = identifierDescriptor;
|
||||
@ -201,10 +195,7 @@ public String getIndexPropertyName() {
|
||||
*/
|
||||
protected PluralAttributeMappingImpl(PluralAttributeMappingImpl original) {
|
||||
super( original );
|
||||
this.propertyAccess = original.propertyAccess;
|
||||
this.attributeMetadata = original.attributeMetadata;
|
||||
this.collectionMappingType = original.collectionMappingType;
|
||||
this.stateArrayPosition = original.stateArrayPosition;
|
||||
this.elementDescriptor = original.elementDescriptor;
|
||||
this.indexDescriptor = original.indexDescriptor;
|
||||
this.identifierDescriptor = original.identifierDescriptor;
|
||||
@ -355,21 +346,6 @@ public boolean containsTableReference(String tableExpression) {
|
||||
return tableExpression.equals( separateCollectionTable );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStateArrayPosition() {
|
||||
return stateArrayPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeMetadata getAttributeMetadata() {
|
||||
return attributeMetadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyAccess getPropertyAccess() {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Generator getGenerator() {
|
||||
// can never be a generated value
|
||||
|
Loading…
x
Reference in New Issue
Block a user