Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Teneo/Hibernate/Collection Extra-Lazy Loading

< Teneo‎ | Hibernate
Revision as of 20:49, 24 March 2010 by Mtaal.springsite.com (Talk | contribs) (New page: __TOC__ As a default collections are lazy loaded, this means that a collection is loaded in memory when it is first accessed but not before. There are collections which are to large to lo...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

As a default collections are lazy loaded, this means that a collection is loaded in memory when it is first accessed but not before. There are collections which are to large to load in memory for standard operations. For these collections it can make sense to make use of the Hibernate extra-lazy functionality. Teneo supports this functionality and facilitates making use of it.

See this blog for some information on Hibernate extra-lazy behavior.

Hibernate only supports extra-lazy loading for lists which are bi-directional and have an explicit property/member for the list-index. Teneo makes it possible to also use the Hibernate extra-lazy mode for uni-directional associations when the list-index is not mapped. Teneo does this by creating so-called synthetic properties which take care of storing this information.

Enabling Extra-Lazy Mapping

Extra-lazy handling can be enabled in two ways:

  • By setting the option PersistenceOptions.

Teneo supports extra-lazy collection handling as it is described in the Hibernate manual .

With extra-lazy handling the following operations are being done in constant time (independent of the collection size):

  • append
  • remove last element in the list
  • get
  • set
  • contains
  • size


Choosing an Alternative Mapping

When you encounter a very large collection in your model then you can also decide to not explicitly map this collection to the database but map the 'other side'. So assume that you have a type called 'Root' which has a collection efeature 'leafs' with thousands of children (the 'Leaf' type). Instead of mapping the collection to the database it can be an option to only map the reference from Leaf to Root (so from child to parent). The Root.leafs collection can then be made transient.

Back to the top