For large binary or text content (database LOB) we can model it in the entity bean as a property of type and with @Lob.

public class SomeFileBean {

  File content;

Lazy fetched by default

By default all @Lob properties are fetched lazy so that means by default they are NOT fetched unless explicit included in the select clause.

Note that File properties (and other Lob properties) will lazy load as needed.

QSomeFileBean b = QSomeFileBean.alias()

SomeFileBean bean =
  new QSomeFileBean()
    .select(, b.content)

File content = bean.getContent();

Content streamed to file

For each File returned Ebean creates a temporary file and streams the content from the database Lob result into the file. As such when we fetch beans with Files we are expected to process the file in some way and then potentially discard, delete or move the temporary file. If we do not then this can result in a build up of temporary files in the temp directory.


// have the content as a File
File tempFile = ...;

UserProfile profile = new UserProfile();

// typically tidy up file


QUserProfile u = QUserProfile.alias()

UserProfile profile =
  new QUserProfile()
    .select(, u.profileImage)

File image = profile.getProfileImage();
// do something with the image file
// maybe move it to a cache directory
// or tidy up by deleting the temporary file

Stateless update

It is often useful to perform a stateless update where we update the File content without fetching it.

// have the content as a File
File updatedProfileImage = ...;

UserProfile profile = new UserProfile();

// perform update without fetching

// typically tidy up file