diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index cf7930d..62557ea 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
@@ -339,6 +339,10 @@ public function getTableMapping() {
    * {@inheritdoc}
    */
   protected function doLoadMultiple(array $ids = NULL) {
+    if (!empty($ids)) {
+      $ids = $this->cleanIds($ids);
+    }
+
     // Build and execute the query.
     $records = $this
       ->buildQuery($ids)
@@ -349,6 +353,30 @@ protected function doLoadMultiple(array $ids = NULL) {
   }
 
   /**
+   * Ensures integer entity IDs are valid.
+   *
+   * The identifier sanitization provided by this method has been introduced
+   * as Drupal used to rely on the database to facilitate this, which worked
+   * correctly with MySQL but led to errors with other DBMS such as PostgreSQL.
+   *
+   * @param array $ids
+   *   The entity IDs to verify.
+   * @return array
+   *   The sanitized list of entity IDs.
+   */
+  protected function cleanIds(array $ids) {
+    $definitions = $this->entityManager->getBaseFieldDefinitions($this->entityTypeId);
+    $id_definition = $definitions[$this->entityType->getKey('id')];
+
+    if ($id_definition->getType() == 'integer') {
+      $ids = array_filter($ids, 'is_numeric');
+      $ids = array_map('intval', $ids);
+      break;
+    }
+    return $ids;
+  }
+
+  /**
    * Maps from storage records to entity objects.
    *
    * This will attach fields, if the entity is fieldable. It calls
diff --git a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
index 4faec44..19515d0 100644
--- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
@@ -76,6 +76,11 @@ function testEntityViewController() {
       $this->assertRaw($entity->label());
       $this->assertRaw('full');
     }
+
+    // As entity_test IDs must be integers, make sure requests for non-integer
+    // IDs return a page not found error.
+    $this->drupalGet('entity_test/invalid');
+    $this->assertResponse(404);
   }
 
   /**
