zwwcn

Just another WordPress.com site

Hibernate extra-lazy fetching strategy

This is very useful feature. if you just want to get size of the children collections but not loading the items into memory, you can add the extra LazyCollection annotation to the field. Be aware that each request for size will trigger a sql select to the DB, so it’s only recommended for large collections.

@OneToMany(mappedBy="shelf")
@OrderBy("date DESC")
@LazyCollection(LazyCollectionOption.EXTRA)
List books = new ArrayList();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: