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/Lob"
m (New page: {{EclipseLink_UserGuide|info=y|toc=n}} =@Lob= {{EclipseLink_JPA |previous=Temporal |next= [[Eclips...) |
m |
||
Line 1: | Line 1: | ||
{{EclipseLink_UserGuide|info=y|toc=n}} | {{EclipseLink_UserGuide|info=y|toc=n}} | ||
=@Lob= | =@Lob= | ||
+ | By default, EclipseLink persistence provider assumes that all persistent data can be represented as typical database data types. | ||
+ | |||
+ | Use the <tt>@Lob</tt> annotation with the [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings|<tt>@Basic</tt> mapping]] to specify that a persistent property or field should be persisted as a large object to a database-supported large object type. | ||
+ | |||
+ | A <tt>Lob</tt> may be either a binary or character type. The persistence provider infers the <tt>Lob</tt> type from the type of the persistent field or property. | ||
+ | |||
+ | For <tt>String</tt> and character-based types, the default is <tt>Clob</tt>. In all other cases, the default is <tt>Blob</tt>. | ||
+ | |||
+ | You can also use the <tt>@Column</tt> attribute <tt>columnDefinition</tt> to further refine the <tt>Lob</tt> type. | ||
+ | {{EclipseLink_Spec | ||
+ | |section=Section 9.1.5 "Column Annotation"}} | ||
+ | |||
+ | The <tt>@Lob</tt> annotation does not have attributes. | ||
+ | |||
+ | This example shows how to use this <tt>@Lob</tt> annotation to specify that persistent field <tt>pic</tt> should be persisted as a <tt>Blob</tt>. | ||
+ | |||
+ | |||
+ | <span id="Example 18-15"></span> | ||
+ | ''''' Usage of the @Lob Annotation''''' | ||
+ | <source lang="java"> | ||
+ | @Entity | ||
+ | public class Employee implements Serializable { | ||
+ | ... | ||
+ | @Lob | ||
+ | @Basic(fetch=LAZY) | ||
+ | @Column(name="EMP_PIC", columnDefinition="BLOB NOT NULL") | ||
+ | protected byte[] pic; | ||
+ | ... | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | {{EclipseLink_Spec | ||
+ | |section=Section 9.1.20 "Temporal Annotation"}} | ||
Line 8: | Line 41: | ||
|next= [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Transient|Transient]] | |next= [[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Transient|Transient]] | ||
|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:54, 21 June 2010
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
@Lob
By default, EclipseLink persistence provider assumes that all persistent data can be represented as typical database data types.
Use the @Lob annotation with the @Basic mapping to specify that a persistent property or field should be persisted as a large object to a database-supported large object type.
A Lob may be either a binary or character type. The persistence provider infers the Lob type from the type of the persistent field or property.
For String and character-based types, the default is Clob. In all other cases, the default is Blob.
You can also use the @Column attribute columnDefinition to further refine the Lob type.
For more information, see Section 9.1.5 "Column Annotation" in the JPA Specification.
The @Lob annotation does not have attributes.
This example shows how to use this @Lob annotation to specify that persistent field pic should be persisted as a Blob.
Usage of the @Lob Annotation
@Entity public class Employee implements Serializable { ... @Lob @Basic(fetch=LAZY) @Column(name="EMP_PIC", columnDefinition="BLOB NOT NULL") protected byte[] pic; ... }
For more information, see Section 9.1.20 "Temporal Annotation" in the JPA Specification.