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.
Talk:EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Default Conversions and Converters/StructConverter
< Talk:EclipseLink/UserGuide/JPA | Basic JPA Development | Mapping/Basic Mappings | Default Conversions and Converters
Revision as of 14:36, 2 May 2011 by Ben.gelernter.oracle.com (Talk | contribs)
-- 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.