Search in sources :

Example 1 with BlobImplementer

use of org.hibernate.engine.jdbc.BlobImplementer in project hibernate-orm by hibernate.

the class LobCreatorTest method testLobCreation.

private void testLobCreation(LobCreator lobCreator) throws SQLException {
    Blob blob = lobCreator.createBlob(new byte[] {});
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(blob instanceof BlobImplementer);
    } else {
        assertTrue(blob instanceof JdbcBlob);
    }
    blob = lobCreator.wrap(blob);
    assertTrue(blob instanceof WrappedBlob);
    Clob clob = lobCreator.createClob("Hi");
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(clob instanceof ClobImplementer);
    } else {
        assertTrue(clob instanceof JdbcClob);
    }
    clob = lobCreator.wrap(clob);
    assertTrue(clob instanceof WrappedClob);
    Clob nclob = lobCreator.createNClob("Hi");
    if (lobCreator == NonContextualLobCreator.INSTANCE) {
        assertTrue(nclob instanceof NClobImplementer);
    } else {
        assertTrue(nclob instanceof JdbcNClob);
    }
    assertTrue(NClob.class.isInstance(nclob));
    nclob = lobCreator.wrap(nclob);
    assertTrue(nclob instanceof WrappedClob);
    blob.free();
    clob.free();
    nclob.free();
}
Also used : WrappedBlob(org.hibernate.engine.jdbc.WrappedBlob) NClob(java.sql.NClob) WrappedBlob(org.hibernate.engine.jdbc.WrappedBlob) Blob(java.sql.Blob) WrappedClob(org.hibernate.engine.jdbc.WrappedClob) NClobImplementer(org.hibernate.engine.jdbc.NClobImplementer) BlobImplementer(org.hibernate.engine.jdbc.BlobImplementer) ClobImplementer(org.hibernate.engine.jdbc.ClobImplementer) NClobImplementer(org.hibernate.engine.jdbc.NClobImplementer) WrappedClob(org.hibernate.engine.jdbc.WrappedClob) NClob(java.sql.NClob) Clob(java.sql.Clob)

Example 2 with BlobImplementer

use of org.hibernate.engine.jdbc.BlobImplementer in project hibernate-orm by hibernate.

the class BlobDescriptorTest method testStreamResetOnAccess.

@Test
@TestForIssue(jiraKey = "HHH-8193")
public void testStreamResetOnAccess() throws IOException {
    byte[] bytes = new byte[] { 1, 2, 3, 4 };
    BlobImplementer blob = (BlobImplementer) BlobProxy.generateProxy(bytes);
    int value = blob.getUnderlyingStream().getInputStream().read();
    // Call to BlobImplementer#getUnderlyingStream() should mark input stream for reset.
    assertEquals(bytes.length, blob.getUnderlyingStream().getInputStream().available());
}
Also used : BlobImplementer(org.hibernate.engine.jdbc.BlobImplementer) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

BlobImplementer (org.hibernate.engine.jdbc.BlobImplementer)2 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 NClob (java.sql.NClob)1 ClobImplementer (org.hibernate.engine.jdbc.ClobImplementer)1 NClobImplementer (org.hibernate.engine.jdbc.NClobImplementer)1 WrappedBlob (org.hibernate.engine.jdbc.WrappedBlob)1 WrappedClob (org.hibernate.engine.jdbc.WrappedClob)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.Test)1