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 "Talk:EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Default Conversions and Converters/StructConverter"

m
m
Line 14: Line 14:
 
::* [[Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Structure Mapping|Object-Relational Data Type Structure Mapping]]
 
::* [[Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Structure Mapping|Object-Relational Data Type Structure Mapping]]
 
::* [[Introduction%20to%20Object-Relational%20Data%20Type%20Descriptors%20(ELUG)|Object-Relational Data Type Descriptors]]
 
::* [[Introduction%20to%20Object-Relational%20Data%20Type%20Descriptors%20(ELUG)|Object-Relational Data Type Descriptors]]
 +
 +
-- [[User:ben.gelernter.oracle.com|Ben Gelernter]] 4/28/11
 +
 +
: More ELUG refs
 +
: I removed the ELUG links from the final section
 +
::==Using Structure Converters to Configure Mappings==
 +
 +
::In EclipseLink, a <tt>DatabasePlatform</tt> (see [[Introduction%20to%20Data%20Access%20(ELUG)#Database Platforms|Database Platforms]]) holds a structure converter. An <tt>org.eclipse.persistence.database.platform.converters.StructConverter</tt> affects all objects of a particular type read into the <tt>Session</tt> that has that <tt>DatabasePlatform</tt>. This prevents you from configuring the <tt>StructConverter</tt> on a mapping-by-mapping basis. To configure mappings that use the <tt>StructConverter</tt>, you call their <tt>setFieldType(java.sql.Types.STRUCT)</tt> method. You must call this method on all mappings that the <tt>StructConverter</tt> will affect – if you do not call it, errors might occur.
 +
 +
::The JPA specification requires all <tt>@Basic</tt> mappings (see [[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@Basic|@Basic]]) that map to a non-primitive or a non-primitive-wrapper type have a serialized converter added to them. This enables certain <tt>STRUCT</tt> types to map to a field without serialization.
 +
 +
::You can use the existing <tt>[[#How to Use the @Convert Annotation|@Convert]]</tt> annotation with its <tt>value</tt> attribute set to the <tt>StructConverter</tt> name – in this case, EclipseLink will apply appropriate settings to the mapping. This setting will be required on all mappings that use a type for which a <tt>StructConverter</tt> has been defined. Failing to configure the mapping with the <tt>@Convert</tt> will cause an error.

Revision as of 14:36, 2 May 2011

-- Ben Gelernter 4/28/11

ELUG ref
I removed this reference that possibly is to ELUG. It currently xrefs a nonexistent target on this page. I suspect is used to be to a section in ELUG.
Return here to see if this information needs to be brought forward into this doc.
Note: You can also configure structure converters in a sessions.xml file (see What You May Need to Know About EclipseLink JPA Overriding Mechanisms).


-- Ben Gelernter 4/28/11

ELUG ref
I also removed these references to ELUG. Return here to see if this information needs to be brought forward into this doc.
For more information, see the following:

-- Ben Gelernter 4/28/11

More ELUG refs
I removed the ELUG links from the final section
==Using Structure Converters to Configure Mappings==
In EclipseLink, a DatabasePlatform (see Database Platforms) holds a structure converter. An org.eclipse.persistence.database.platform.converters.StructConverter affects all objects of a particular type read into the Session that has that DatabasePlatform. This prevents you from configuring the StructConverter on a mapping-by-mapping basis. To configure mappings that use the StructConverter, you call their setFieldType(java.sql.Types.STRUCT) method. You must call this method on all mappings that the StructConverter will affect – if you do not call it, errors might occur.
The JPA specification requires all @Basic mappings (see @Basic) that map to a non-primitive or a non-primitive-wrapper type have a serialized converter added to them. This enables certain STRUCT types to map to a field without serialization.
You can use the existing @Convert annotation with its value attribute set to the StructConverter name – in this case, EclipseLink will apply appropriate settings to the mapping. This setting will be required on all mappings that use a type for which a StructConverter has been defined. Failing to configure the mapping with the @Convert will cause an error.

Back to the top