diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php
index <HASH>..<HASH> 100644
--- a/lib/Doctrine/ORM/Query.php
+++ b/lib/Doctrine/ORM/Query.php
@@ -649,6 +649,10 @@ final class Query extends AbstractQuery
      */
     public function setFirstResult($firstResult): self
     {
+        if ($firstResult !== null) {
+            $firstResult = (int) $firstResult;
+        }
+
         $this->firstResult = $firstResult;
         $this->_state      = self::STATE_DIRTY;
 
diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php
index <HASH>..<HASH> 100644
--- a/lib/Doctrine/ORM/QueryBuilder.php
+++ b/lib/Doctrine/ORM/QueryBuilder.php
@@ -627,6 +627,10 @@ class QueryBuilder
      */
     public function setFirstResult($firstResult)
     {
+        if ($firstResult !== null) {
+            $firstResult = (int) $firstResult;
+        }
+
         $this->_firstResult = $firstResult;
 
         return $this;
Add integer cast in setFirstResult methods of Query and QueryBuilder (#<I>)