diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
index e98755ae879eb28c021207b28f33ee0245d3c2c9..05782dd4e53b28fe517ee22e2c6216ff29e575b9 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
@@ -210,9 +210,7 @@ public function range($start = NULL, $length = NULL) {
    *   An object holding a group of conditions.
    */
   protected function conditionGroupFactory($conjunction = 'AND') {
-    // As the factory classes hardwire QueryBase::getClass, it needs to be
-    // hardwired here too.
-    $class = QueryBase::getClass($this->namespaces, 'Condition');
+    $class = static::getClass($this->namespaces, 'Condition');
     return new $class($conjunction, $this, $this->namespaces);
   }
 
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
index 407cef517f90b86c9ee87a625fb01d122f98efd6..cf8eb39502cf543eb6e445b118655179a2436d6d 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
@@ -311,7 +311,7 @@ public function __clone() {
    *   The object that adds tables and fields to the SQL query object.
    */
   public function getTables(SelectInterface $sql_query) {
-    $class = QueryBase::getClass($this->namespaces, 'Tables');
+    $class = static::getClass($this->namespaces, 'Tables');
     return new $class($sql_query);
   }