120 words

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

#1
2014-06-10 22:52

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?

Vladiator
Vladiator's picture
Joined on 2013-10-20
User Post #5
#2
2014-06-10 23:14

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #1,952

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel