OpenJPA1.2 - Lazy BLOB Download

I have a very simple JPA object. It contains several simple metadata fields, as well as an identifier and a large payload of ~ 500 kB-10 MB.

@Entity
public class MyEntity{
  @Id
  @GenerateValue(Strategy=GenerationType.IDENTITY)
  private long myEntityId;

  private String metaData1; 
  ..
  private String metaDataN;

  @Lob
  private String payload; // large.

}

In most cases, I do not alternate when loading in a payload, but simply request metadata fields. Is there a way to load the payload lazy without creating a specific object that wraps the payload and has a one-to-one relationship from lazy load to one of my main object?

All of this is implemented using OpenJPA 1.2 and the DB2 support database.

+3
source share
3 answers
@Lob
@Basic(fetch=FetchType.LAZY)
private String payload;
+8
source

I think you can also use:

@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(//some col. name)
private String payload;
0
source

Hibernate lob, Lob

0

All Articles