@Lob @Basic(fetch = FetchType.LAZY) is loaded when it's not needed

#1

Hello. I have a class Thing that contains OneToMany list of classes Photo. Photo contains 

@Lob

@Basic(fetch = FetchType.LAZY)

private byte[] content;

And after some queries with Thing (but without loading content of the photos) I get java.lang.OutOfMemoryError: Java heap space (the server is started with -Xmx4096M). Heap dump shows that there are very much space is used by contents of the photos despite of using fetch = FetchType.LAZY. How can I fix this memory issue?

#2

FetchType.LAZY is a hint that JPA implementations are allowed to ignore.

Currently ObjectDB always loads basic types eagerly.

Consider replacing byte[] with a wrapper entity (e.g. Data) that will contain the byte[] content, since lazy loading of relationships to entities can be loaded lazily.

ObjectDB Support

Reply