com.vaadin.addon.jpacontainer.util
Class HibernateLazyLoadingDelegate

java.lang.Object
  extended by com.vaadin.addon.jpacontainer.util.HibernateLazyLoadingDelegate
All Implemented Interfaces:
LazyLoadingDelegate

public class HibernateLazyLoadingDelegate
extends Object
implements LazyLoadingDelegate

HibernateLazyLoadingDelegate is the default implementation of the LazyLoadingDelegate interface for use with Hibernate. Note that EclipseLink does not require any lazy loading delegates in order for lazy loading to transparently work. HibernateLazyLoadingDelegate handles lazy loaded properties by explicitly loading the property in question from the database and attaching it to the entity passed in. This happens recursively if the property is nested.

Since:
2.0
Author:
Jonatan Kronqvist / Vaadin Ltd

Constructor Summary
HibernateLazyLoadingDelegate()
           
 
Method Summary
<E> E
ensureLazyPropertyLoaded(E entity, String propertyName)
          This method is called when a lazily loaded property is accessed in an entity.
 void setEntityProvider(EntityProvider<?> ep)
          Sets the EntityProvider that this delegate is associated with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateLazyLoadingDelegate

public HibernateLazyLoadingDelegate()
Method Detail

setEntityProvider

public void setEntityProvider(EntityProvider<?> ep)
Description copied from interface: LazyLoadingDelegate
Sets the EntityProvider that this delegate is associated with. Automatically called by EntityProvider.setLazyLoadingDelegate(LazyLoadingDelegate). The EntityProvider is used to get the current EntityManager.

Specified by:
setEntityProvider in interface LazyLoadingDelegate

ensureLazyPropertyLoaded

public <E> E ensureLazyPropertyLoaded(E entity,
                                      String propertyName)
Description copied from interface: LazyLoadingDelegate
This method is called when a lazily loaded property is accessed in an entity. The implementation of this method is responsible for ensuring that the property in question is accessible on the instance of entity that is returned.

Specified by:
ensureLazyPropertyLoaded in interface LazyLoadingDelegate
Parameters:
entity - The entity containing a lazy property.
propertyName - The name of the lazy property to be accessed.
Returns:
an instance of entity with propertyName attached and accessible. This may be the same instance as passed in or a new one.


Copyright © 2013 Vaadin Ltd. All rights reserved.