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/Default Conversions and Converters/Convert"
< EclipseLink | UserGuide | JPA | Basic JPA Development | Mapping | Basic Mappings | Default Conversions and Converters
m |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 10: | Line 10: | ||
}} | }} | ||
− | =@Convert | + | =@Convert= |
The <tt>@Convert</tt> annotation specifies that a named converter should be used with the corresponding mapped attribute. | The <tt>@Convert</tt> annotation specifies that a named converter should be used with the corresponding mapped attribute. | ||
<source lang="java"> | <source lang="java"> | ||
Line 61: | Line 61: | ||
{{EclipseLink_JPA | {{EclipseLink_JPA | ||
− | |previous=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/StructConverter| | + | |previous=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters/StructConverter|@StructConverter]] |
|next= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Lazy_Basics|Lazy Basics]] | |next= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Lazy_Basics|Lazy Basics]] | ||
|up= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters|Default Conversions and Converters]] | |up= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Basic_Mappings/Default_Conversions_and_Converters|Default Conversions and Converters]] | ||
|version=2.2.0 DRAFT}} | |version=2.2.0 DRAFT}} |
Latest revision as of 10:09, 5 May 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
@Convert
The @Convert annotation specifies that a named converter should be used with the corresponding mapped attribute.
@Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface Convert { String value() default "none"; }
The @Convert has the following reserved names:
- serialized – places the org.eclipse.persistence.mappings.converters.SerializedObjectConverter on the associated mapping.
- none – does not place a converter on the associated mapping.
Attribute | Description | Default | Required? |
---|---|---|---|
value | The String name for your converter. | "none" String | No |
The following example shows how to use the @Convert annotation to define the Employee field gender.
Example: @Convert Annotation
@Entity @Table(name="EMPLOYEE") @Converter( name="genderConverter", converterClass=org.myorg.converters.GenderConverter.class ) public class Employee implements Serializable{ ... @Basic @Convert("genderConverter") public String getGender() { return gender; } ... }