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/Basic JPA Development/Mapping/Basic Mappings/Default Conversions and Converters"

m
m
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide}}
+
{{EclipseLink_UserGuide|info=y
 +
|api=y
 +
|apis=
 +
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/Converter.html @Converter]
 +
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/TypeConverter.html @TypeConverter]
 +
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/ObjectTypeConverter.html @ObjectTypeConverter]
 +
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/StructConverter.html @StructConverter]
 +
* [http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/Convert.html @Convert]
 +
}}
 +
 
 
=Default Conversions and Converters=
 
=Default Conversions and Converters=
 
EclipseLink defines the following converter annotations and XML attributes (in addition to JPA-defined ones):
 
EclipseLink defines the following converter annotations and XML attributes (in addition to JPA-defined ones):
  
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Converter|@Converter and <converter>]]</tt>
+
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Converter|@Converter]]</tt>
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/TypeConverter|@TypeConverter and <type-converter>]]</tt>
+
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/TypeConverter|@TypeConverter]]</tt>
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/ObjectTypeConverter|@ObjectTypeConverter and <object-type-converter>]]</tt>
+
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/ObjectTypeConverter|@ObjectTypeConverter]]</tt>
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/StructConverter|@StructConverter and <struct-converter>]]</tt>
+
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/StructConverter|@StructConverter]]</tt>
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Convert|@Convert and <convert>]]</tt>
+
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Convert|@Convert]]</tt>
  
 
EclipseLink persistence provider searches the converter annotations in the following order:
 
EclipseLink persistence provider searches the converter annotations in the following order:
  
* <tt>[[#How to Use the @Convert Annotation|@Convert]]</tt>
+
# <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Convert|@Convert]]</tt>
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Enumerated|@Enumerated]]</tt>
+
# <tt>@Enumerated|@Enumerated</tt>
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Lob|@Lob]]</tt>
+
# <tt>@Lob</tt>
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Temporal|@Temporal]]</tt>
+
# <tt>@Temporal</tt>
* Serialized (automatic)
+
# Serialized (automatic)
  
 
You can define converters at the class, field and property level. You can specify EclipseLink converters on the following classes:
 
You can define converters at the class, field and property level. You can specify EclipseLink converters on the following classes:
  
* <tt>@Entity</tt> {{EclipseLink_Spec|section=Section 8.1 "Entity"}}
+
* <tt>@Entity</tt>  
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@MappedSuperclass|@MappedSuperclass]]</tt>
+
* <tt>@MappedSuperclass</tt>
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Embeddable|@Embeddable]]</tt>
+
* <tt>@Embeddable</tt>
  
 
You can use EclipseLink converters with the following mappings:
 
You can use EclipseLink converters with the following mappings:
  
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Basic|@Basic]]</tt>
+
* <tt>@Basic</tt>
* <tt>[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Entity/Id|@Id]]</tt>
+
* <tt>@Id</tt>
* <tt>[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#Configuring Locking|@Version]]</tt>
+
* <tt>@Version</tt>
* <tt>[[#How to Use the @BasicMap Annotation|@BasicMap]]</tt>
+
* <tt>@BasicMap</tt>
* <tt>[[#How to Use the @BasicCollection Annotation|@BasicCollection]]</tt>
+
* <tt>@BasicCollection</tt>
  
 
If you specify a converter with any other type of mapping annotation, EclipseLink will throw an exception.
 
If you specify a converter with any other type of mapping annotation, EclipseLink will throw an exception.
Line 35: Line 44:
  
 
{{EclipseLink_JPA
 
{{EclipseLink_JPA
|previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Column|Column]]
+
|previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Column|@Column]]
 
|next=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Converter|@Converter]]
 
|next=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/Converter|@Converter]]
 
|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
+
|version=2.2.0 DRAFT
 
}}
 
}}

Latest revision as of 10:02, 5 May 2011



Default Conversions and Converters

EclipseLink defines the following converter annotations and XML attributes (in addition to JPA-defined ones):

EclipseLink persistence provider searches the converter annotations in the following order:

  1. @Convert
  2. @Enumerated|@Enumerated
  3. @Lob
  4. @Temporal
  5. Serialized (automatic)

You can define converters at the class, field and property level. You can specify EclipseLink converters on the following classes:

  • @Entity
  • @MappedSuperclass
  • @Embeddable

You can use EclipseLink converters with the following mappings:

  • @Basic
  • @Id
  • @Version
  • @BasicMap
  • @BasicCollection

If you specify a converter with any other type of mapping annotation, EclipseLink will throw an exception.


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

Back to the top