Jump to: navigation, search

EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Transient

< EclipseLink‎ | UserGuide‎ | JPA‎ | Basic JPA Development‎ | Mapping‎ | Basic Mappings
Revision as of 14:16, 27 October 2011 by James.sutherland.oracle.com (Talk | contribs)

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

EclipseLink JPA

Mailing ListForumsIRC
Help Wanted
Bug Day
Browse Source

Elug api package icon.png Key API


By default, EclipseLink persistence provider assumes that all the fields of an entity are persistent.

Use the @Transient annotation or <transient> XML to specify a field or property of an entity that is not persistent (for example, a field or property that is used at run time, but that is not part of the entity's state).

EclipseLink persistence provider will not persist (or create database schema) for a property or field annotated with @Transient.

This annotation can be used with @Entity, @MappedSuperclass, and @Embeddable.

Elug javaspec icon.gif

For more information, see Section 8.1 "Entity" in the JPA Specification.

The @Transient annotation does not have attributes.

If a field is marked as Java transient it will also be ignored.

The following example shows how to use the @Transient annotation to specify Employee field currentSession as not persistent. EclipseLink persistence provider will not persist this field.

Example: @Transient Annotation
public class Employee implements Serializable {
    int id;
    Session currentSession;
Example: Using <transient> XML
<entity class="Employee">
        <id name="id"/>
        <transient name="currentSession"/>
Elug javaspec icon.gif

For more information, see Section 11.1.48 "Transient Annotation" in the JPA Specification.

Version: 2.1.0
Other versions...