3.8.7.11. LOB Streaming

In addition to handling LOBs in a standard JPA manner (LOB annotation and lob XML element), OpenJPA supports LOB streaming. This feature makes it possible to stream large amounts of data into and out of persistent field without ever holding all the data in memory at the same time.

LOB streaming is supported on the following databases.

  • MySQL

  • Oracle

  • PostgreSQL

  • SQL Server

  • DB2

See Supported Databases for possible database-specific restrictions.

To persist a stream, apply the org.apache.openjpa.persistence.Persistent annotation to either java.io.InputStream or java.io.Reader field.

Example 126. Annotated InputStream and Reader
@Entity
public class Employee {
    ...
    @Persistent
    private InputStream photoStream;

    @Persistent
    private Reader photoDescription;
    ...
}