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.
Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Transient"
m |
(→@Transient) |
||
Line 12: | Line 12: | ||
By default, EclipseLink persistence provider assumes that all the fields of an entity are persistent. | 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). | + | Use the <tt>@Transient</tt> annotation or <code><transient</code> 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 <tt>@Transient</tt>. | 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>]] | + | This annotation can be used with <tt>@Entity</tt>, [[#@MappedSuperclass|<tt>@MappedSuperclass</tt>]], and [[#@Embeddable|<tt>@Embeddable</tt>]]. |
{{EclipseLink_Spec | {{EclipseLink_Spec | ||
|section=Section 8.1 "Entity"}} | |section=Section 8.1 "Entity"}} | ||
Line 26: | Line 26: | ||
======'' Example: @Transient Annotation''====== | ======'' Example: @Transient Annotation''====== | ||
<source lang="java"> | <source lang="java"> | ||
− | + | @Entity | |
− | + | public class Employee implements Serializable { | |
− | + | ... | |
− | + | @Id | |
− | + | int id; | |
− | + | ||
− | + | @Transient | |
− | + | Session currentSession; | |
− | + | ... | |
− | + | } | |
</source> | </source> | ||
Revision as of 14:51, 27 October 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
@Transient
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.
For more information, see Section 8.1 "Entity" in the JPA Specification.
The @Transient annotation does not have attributes.
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
@Entity public class Employee implements Serializable { ... @Id int id; @Transient Session currentSession; ... }
For more information, see Section 11.1.48 "Transient Annotation" in the JPA Specification.
@Lob | @Column | |
EclipseLink Home
JPA User Guide: Table of Contents, Search |
||
How to contribute to this guide... |