Skip to main content

Notice: This Wiki is now read only and edits are no longer 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/Basic JPA Development/Mapping/Basic Mappings/Transient"

m (New page: {{EclipseLink_UserGuide|info=y|toc=n}} =@Transient= {{EclipseLink_JPA |previous=Temporal |next= ...)
 
m
Line 1: Line 1:
 
{{EclipseLink_UserGuide|info=y|toc=n}}
 
{{EclipseLink_UserGuide|info=y|toc=n}}
 
=@Transient=
 
=@Transient=
 +
By default, EclipseLink persistence provider assumes that all the fields of an entity are persistent.
 +
 +
Use the <tt>@Transient</tt> annotation 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 <tt>@Transient</tt>.
 +
 +
This annotation can be used with <tt>@Entity</tt>, [[#@MappedSuperclass|<tt>@MappedSuperclass</tt>]]), and [[#@Embeddable|<tt>@Embeddable</tt>]].
 +
{{EclipseLink_Spec
 +
|section=Section 8.1 "Entity"}}
 +
 +
The <tt>@Transient</tt> annotation does not have attributes.
 +
 +
The [[#Example 18-16|Usage of the @Transient Annotation]] example shows how to use the <tt>@Transient</tt> annotation to specify <tt>Employee</tt> field <tt>currentSession</tt> as not persistent. EclipseLink persistence provider will not persist this field.
 +
 +
 +
<span id="Example 18-16"></span>
 +
''''' Usage of the @Transient Annotation'''''
 +
<source lang="java">
 +
@Entity
 +
public class Employee implements Serializable {
 +
    ...
 +
    @Id
 +
    int id;
 +
 +
    @Transient
 +
    Session currentSession;
 +
    ...
 +
}
 +
</source>
 +
 +
{{EclipseLink_Spec
 +
|section=Section 9.1.16 "Transient Annotation"}}
  
  
Line 8: Line 40:
 
|next=    [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Column|Column]]
 
|next=    [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Column|Column]]
 
|up=      [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings|Basic Mappings]]
 
|up=      [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings|Basic Mappings]]
}}
+
|version= 2.1.0}}

Revision as of 09:56, 21 June 2010


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

@Transient

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

Use the @Transient annotation 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.

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


Usage of the @Transient Annotation

 @Entity
 public class Employee implements Serializable {
     ...
     @Id
     int id;
 
     @Transient
     Session currentSession;
     ...
 }
Elug javaspec icon.gif

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


Eclipselink-logo.gif
Version: 2.1.0
Other versions...

Back to the top