diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/BlobProxy.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/BlobProxy.java index 4675c41fa5..7f9bd36d53 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/BlobProxy.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/BlobProxy.java @@ -201,7 +201,7 @@ public final class BlobProxy implements Blob, BlobImplementer { @Override public long getLength() { - return (int) length; + return length; } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/engine/jdbc/BlobProxyTest.java b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/BlobProxyTest.java new file mode 100644 index 0000000000..dd0068550b --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/engine/jdbc/BlobProxyTest.java @@ -0,0 +1,20 @@ +package org.hibernate.engine.jdbc; + +import org.hibernate.testing.orm.junit.JiraKey; +import org.junit.jupiter.api.Test; + +import java.sql.Blob; +import java.sql.SQLException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@JiraKey("HHH-17770") +class BlobProxyTest { + + @Test + void testLengthIsNotTruncated() throws SQLException { + long THREE_GB = 3 * 1024 * 1024 * 1024L; + Blob blob = BlobProxy.generateProxy(null, THREE_GB); + assertEquals(THREE_GB, blob.length()); + } +}