I have a JPA entity with java.sql.Blob:
@Entity
public class LargeData {
@Lob
private java.sql.Blob data;
//getters/setters
}
How to create instance of this entity? I want to set Blob
with setData()
method, but how to get Blob
from JPA? java.sql.Blob
is only interface, there are different implementations for different databases, so I assume JPA should give me right implementation. How to get it?
Use a byte array:
@Lob
@Column(length=100000)
private byte[] data;
If you want to use streams, create the blob using Hibernate.createBlob(..)