I have an application which has to handle a list of objects (retrieved from the database using JPA) which contain an image serialized.
The issue is that when I get around 50 instances of this object stored on the database, it becomes quite slow to load 50 pictures from the database (~5 seconds), which becomes annoying to the user.
Is there a way to set this column from the database to a lazy initialization? Or should I create a separate object to carry the image, and reference it using an ID?
Thanks for your help.
Yes there is a layz loading attriubte for properties.
From the JPA 2.0 Specification
One other technique would to have a second mapping of the same table, but only with the attributes you need.