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

Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/Performance/Weaving/Weaving POJO Classes"

m (New page: =Weaving POJO Classes= {{EclipseLink_JPA |previous=Weaving JPA Entities |next =[[EclipseLink/U...)
 
m (page obsolete)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
----
 +
 +
 +
'''[[Image:Elug_draft_icon.png|Warning]] This page is now obsolete. '''
 +
 +
For current information, please see "About Weaving" in the ''Understanding EclipseLink (Concepts Guide)'':
 +
http://www.eclipse.org/eclipselink/documentation/latest/concepts/app_dev007.htm
 +
 +
 +
----
 +
 +
 +
{{EclipseLink_UserGuide
 +
|info=y
 +
|toc=n
 +
|eclipselink=y
 +
|eclipselinktype=JPA}}
 
=Weaving POJO Classes=
 
=Weaving POJO Classes=
 +
EclipseLink uses weaving to enable the following for POJO classes:
 +
* Lazy loading
 +
* Change tracking
 +
* Fetch groups
 +
 +
<!--
 +
* [[Configuring%20a%20Mapping%20(ELUG)#Configuring Indirection (Lazy Loading)|lazy loading (indirection)]]
 +
* [[Configuring%20a%20Descriptor%20(ELUG)#Configuring Change Policy|change tracking]]
 +
* [[Configuring%20a%20Descriptor%20(ELUG)#Configuring Fetch Groups|fetch groups]]
 +
* internal optimizations.
 +
-->
 +
EclipseLink weaves all the POJO classes in the JAR you create when you package a POJO application for weaving, as described in [[#Packaging a POJO Application for Weaving|Packaging a POJO Application for Weaving]], below.
 +
 +
EclipseLink weaves all the classes defined in the <tt>persistence.xml</tt> file, that is:
 +
* all the classes you list in the persistence.xml file;
 +
* all classes relative to the JAR containing the <tt>persistence.xml</tt> file if element <tt><exclude-unlisted-classes></tt> is <tt>false</tt>.
 +
 +
==Packaging a POJO Application for Weaving==
 +
To package a POJO application for weaving, you create a JAR that contains a <tt>sessions.xml</tt> file and a <tt>persistence.xml</tt> file, as described below:
 +
 +
<ol>
 +
<li>Create a <tt>sessions.xml</tt> file for your application.<br>For more information, see [[Introduction%20to%20EclipseLink%20Sessions%20(ELUG)|Introduction to EclipseLink Sessions]].</li>
 +
<li>Create a <tt>persistence.</tt>xml file for your application and reference your <tt>sessions.xml</tt> file, as the following example shows.<br><span id="Example 2-8"></span>'''''persistence.xml File for an EclipseLink JPA Application''''' <br>
 +
<div class="pre">
 +
<persistence>
 +
    <persistence-unit name="appname">
 +
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
 +
        <properties>
 +
 +
            <property
 +
                name="eclipselink.session-name"
 +
                value="appname-session"
 +
            >
 +
            <property
 +
                name="eclipselink.sessions-xml"
 +
                value="sessions.xml"
 +
            >
 +
        </properties>
 +
    </persistence-unit>
 +
</persistence>
 +
</div>
 +
</li>
 +
<li> Create a JAR file that contains your POJO classes, <tt>sessions.xml</tt> file, and <tt>persistence.xml</tt> file, as the following example shows.<br>Put both the <tt>persistence.xml</tt> and <tt>sessions.xml</tt> file in a <tt>META-INF</tt> directory.<br>
 +
<span id="Example 2-9"></span>
 +
'''''JAR File for a POJO Application'''''
 +
<div class="pre">
 +
appname.jar
 +
    META-INF
 +
        persistence.xml
 +
        sessions.xml
 +
    *.java
 +
</div>
 +
</li>
 +
<li> Weave the JAR.<br>For more information, see the following:
 +
* [[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Dynamic_Weaving|Configuring Dynamic Weaving]]
 +
* [[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving|Configuring Static Weaving]]
 +
</li></ol>
  
  
 
{{EclipseLink_JPA
 
{{EclipseLink_JPA
|previous=[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/About Weaving|Weaving JPA Entities]]
+
|previous=[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving|Static Weaving]]
 
|next    =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/About Weaving/Weaving and Java EE Application Servers|Weaving and Java EE Application Servers]]
 
|next    =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/About Weaving/Weaving and Java EE Application Servers|Weaving and Java EE Application Servers]]
 
|up      =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/About Weaving|About Weaving]]
 
|up      =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/About Weaving|About Weaving]]
}}
+
|version=2.2.0 DRAFT}}

Latest revision as of 14:27, 23 April 2013



Warning This page is now obsolete.

For current information, please see "About Weaving" in the Understanding EclipseLink (Concepts Guide): http://www.eclipse.org/eclipselink/documentation/latest/concepts/app_dev007.htm




EclipseLink JPA

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

Weaving POJO Classes

EclipseLink uses weaving to enable the following for POJO classes:

  • Lazy loading
  • Change tracking
  • Fetch groups

EclipseLink weaves all the POJO classes in the JAR you create when you package a POJO application for weaving, as described in Packaging a POJO Application for Weaving, below.

EclipseLink weaves all the classes defined in the persistence.xml file, that is:

  • all the classes you list in the persistence.xml file;
  • all classes relative to the JAR containing the persistence.xml file if element <exclude-unlisted-classes> is false.

Packaging a POJO Application for Weaving

To package a POJO application for weaving, you create a JAR that contains a sessions.xml file and a persistence.xml file, as described below:

  1. Create a sessions.xml file for your application.
    For more information, see Introduction to EclipseLink Sessions.
  2. Create a persistence.xml file for your application and reference your sessions.xml file, as the following example shows.
    persistence.xml File for an EclipseLink JPA Application
    <persistence>
        <persistence-unit name="appname">
            <exclude-unlisted-classes>false</exclude-unlisted-classes>
            <properties>
    
                <property
                    name="eclipselink.session-name"
                    value="appname-session"
                >
                <property
                    name="eclipselink.sessions-xml"
                    value="sessions.xml"
                >
            </properties>
        </persistence-unit>
    </persistence>
    
  3. Create a JAR file that contains your POJO classes, sessions.xml file, and persistence.xml file, as the following example shows.
    Put both the persistence.xml and sessions.xml file in a META-INF directory.
    JAR File for a POJO Application
    appname.jar
        META-INF
            persistence.xml
            sessions.xml
        *.java
    
  4. Weave the JAR.
    For more information, see the following:


Eclipselink-logo.gif
Version: 2.2.0 DRAFT
Other versions...

Back to the top