Skip to content

Commit 2813486

Browse files
committedJan 6, 2025
remove lots of unnecessary calls to getRuntimeMetamodels()
I completely understand the desire to not go to the SessionFactoryImplementor for everything, and I'm totally onboard with that, but this isn't actually helping at all (if there ever came a time when we needed to, we can inline those convenience methods completely *trivially*). If we want to actually not depend on the SFI, we need to start passing RuntimeMetamodelsImplementor around instead. That would be *awesome* but it's probably a lot more work. For now the value of the convenience methods is clear, it seems to me.
1 parent 2351f5a commit 2813486

File tree

48 files changed

+170
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+170
-220
lines changed
 

Diff for: ‎hibernate-core/src/main/java/org/hibernate/action/internal/BulkOperationCleanupAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public BulkOperationCleanupAction(SharedSessionContractImplementor session, Enti
111111
public BulkOperationCleanupAction(SharedSessionContractImplementor session, Set<String> tableSpaces) {
112112
final LinkedHashSet<String> spacesList = new LinkedHashSet<>( tableSpaces );
113113

114-
final MappingMetamodelImplementor metamodel = session.getFactory().getRuntimeMetamodels().getMappingMetamodel();
114+
final MappingMetamodelImplementor metamodel = session.getFactory().getMappingMetamodel();
115115
metamodel.forEachEntityDescriptor( (entityDescriptor) -> {
116116
final String[] entitySpaces = (String[]) entityDescriptor.getQuerySpaces();
117117
if ( affectedEntity( tableSpaces, entitySpaces ) ) {
@@ -143,7 +143,7 @@ public BulkOperationCleanupAction(SharedSessionContractImplementor session, Set<
143143

144144
public static void schedule(SharedSessionContractImplementor session, SqmDmlStatement<?> statement) {
145145
final List<EntityPersister> entityPersisters = new ArrayList<>( 1 );
146-
final MappingMetamodelImplementor metamodel = session.getFactory().getRuntimeMetamodels().getMappingMetamodel();
146+
final MappingMetamodelImplementor metamodel = session.getFactory().getMappingMetamodel();
147147
if ( !( statement instanceof InsertSelectStatement ) ) {
148148
entityPersisters.add( metamodel.getEntityDescriptor( statement.getTarget().getEntityName() ) );
149149
}

Diff for: ‎hibernate-core/src/main/java/org/hibernate/action/internal/UnresolvedEntityInsertActions.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,10 @@ private void logCannotResolveNonNullableTransientDependencies(SharedSessionContr
130130
for ( Map.Entry<Object,Set<AbstractEntityInsertAction>> entry : dependentActionsByTransientEntity.entrySet() ) {
131131
final Object transientEntity = entry.getKey();
132132
final String transientEntityName = session.guessEntityName( transientEntity );
133-
final Object transientEntityId = session.getFactory()
134-
.getRuntimeMetamodels()
135-
.getMappingMetamodel()
136-
.getEntityDescriptor( transientEntityName )
137-
.getIdentifier( transientEntity, session );
133+
final Object transientEntityId =
134+
session.getFactory().getMappingMetamodel()
135+
.getEntityDescriptor( transientEntityName )
136+
.getIdentifier( transientEntity, session );
138137
final String transientEntityString = infoString( transientEntityName, transientEntityId );
139138
final Set<String> dependentEntityStrings = new TreeSet<>();
140139
final Set<String> nonNullableTransientPropertyPaths = new TreeSet<>();

0 commit comments

Comments
 (0)
Please sign in to comment.