The JPA specification defines the EAGER and LAZY fetch types.
The SAP implementation of JPA supports lazy loading of single-valued and collection-valued relationships. For downward compatibility with releases prior to SAP NetWeaver 7.3, lazy loading of single-valued relationships must be enabled explicitly, as described below. Otherwise, such entities are loaded eagerly.
Lazy loading is not possible for entities that are part of an inheritance hierarchy.
For more information about fetch types, refer to the Java Persistence API specification.
You have:
Created a project (for example, JPA, EJB, or Dynamic Web) to store the entities with the Java Persistence facet enabled
For more information, see Creating JPA Projects in the Developer Studio .
Added the project containing your entities to an Enterprise Application (EAR) project
For more information, see Assembling Components into Enterprise Applications .
Lazy loading of entities with single-valued relationships requires generation of proxy classes for the lazily loadable entities.
In the persistence.xml , enable generation of proxy classes.
<property name="com.sap.jpa.execution.generate-proxies" value="true" />
In the application-j2ee-engine.xml , set a reference to the cglib_nodep_22 library.
<reference reference-type="hard"> <reference-target provider-name="sap.com" target-type="library">cglib_nodep_22</reference-target> </reference>
For more information, see Editing the application-j2ee-engine.xml .
The EntityManager.getReference method now returns lazily loadable instances.