Package org.hibernate.engine.jdbc
Class BlobProxy
- java.lang.Object
-
- org.hibernate.engine.jdbc.BlobProxy
-
- All Implemented Interfaces:
Blob
,BlobImplementer
@Internal public final class BlobProxy extends Object implements Blob, BlobImplementer
Manages aspects of representingBlob
objects.- See Also:
ClobProxy
,LobCreator
,LobHelper
- API Note:
- This class is not intended to be called directly by the application program.
Instead, use
Session.getLobHelper()
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
free()
static Blob
generateProxy(byte[] bytes)
Generates a BlobImpl using byte data.static Blob
generateProxy(InputStream stream, long length)
Generates a BlobImpl proxy using a given number of bytes from an InputStream.InputStream
getBinaryStream()
InputStream
getBinaryStream(long start, long length)
byte[]
getBytes(long start, int length)
BinaryStream
getUnderlyingStream()
Gets access to the data underlying this BLOB.long
length()
long
position(byte[] pattern, long start)
long
position(Blob pattern, long start)
OutputStream
setBinaryStream(long pos)
int
setBytes(long pos, byte[] bytes)
int
setBytes(long pos, byte[] bytes, int offset, int len)
void
truncate(long len)
-
-
-
Method Detail
-
getUnderlyingStream
public BinaryStream getUnderlyingStream() throws SQLException
Description copied from interface:BlobImplementer
Gets access to the data underlying this BLOB.- Specified by:
getUnderlyingStream
in interfaceBlobImplementer
- Returns:
- Access to the underlying data.
- Throws:
SQLException
-
generateProxy
public static Blob generateProxy(byte[] bytes)
Generates a BlobImpl using byte data.- Parameters:
bytes
- The data to be created as a Blob.- Returns:
- The BlobProxy instance to represent this data.
-
generateProxy
public static Blob generateProxy(InputStream stream, long length)
Generates a BlobImpl proxy using a given number of bytes from an InputStream. Be aware that certain database drivers will automatically close the provided InputStream after the contents have been written to the database. This may cause unintended side effects if the entity is also audited by Envers. In this case, it's recommended to usegenerateProxy(byte[])
instead as it isn't affected by this non-standard behavior.- Parameters:
stream
- The input stream of bytes to be created as a Blob.length
- The number of bytes from stream to be written to the Blob.- Returns:
- The BlobProxy instance to represent this data.
-
length
public long length() throws SQLException
- Specified by:
length
in interfaceBlob
- Throws:
SQLException
-
getBytes
public byte[] getBytes(long start, int length) throws SQLException
- Specified by:
getBytes
in interfaceBlob
- Throws:
SQLException
-
getBinaryStream
public InputStream getBinaryStream() throws SQLException
- Specified by:
getBinaryStream
in interfaceBlob
- Throws:
SQLException
-
setBytes
public int setBytes(long pos, byte[] bytes, int offset, int len)
-
setBinaryStream
public OutputStream setBinaryStream(long pos)
- Specified by:
setBinaryStream
in interfaceBlob
-
getBinaryStream
public InputStream getBinaryStream(long start, long length) throws SQLException
- Specified by:
getBinaryStream
in interfaceBlob
- Throws:
SQLException
-
-