users@glassfish.java.net

Re: TopLink Essentials JPA Converter annotation

From: <glassfish_at_javadesktop.org>
Date: Mon, 04 Jun 2007 08:27:31 PDT

These jpa extension annotations are currently only available in the 11g preview of Oracle TopLink.

In TopLink essentials you can still make use of the Converter as you have designed it but you will need to add the converter to the TopLink mapping directly through a customization class.

Here is an example of how you would add the converter using a Session Customizer.

[u]Persistence.xml entry:[/u]
[code]
<property name="toplink.session.customizer" value="mypackage.ConverterCustomizer"/>
[/code]

[u]Customizer Class :[/u]
[code]
package mypackage;
import oracle.toplink.essentials.sessions.Session;
import oracle.toplink.essentials.mappings.DirectToFieldMapping;
import oracle.toplink.descriptors.RelationalDescriptor;

/**
* PUBLIC:
* This interface is to allow extra customization on a TopLink Session
*/
public class ConverterCustomizer extends SessionCustomizer {
    public void customize(Session session) throws Exception {
        RelationalDescriptor descriptor = session.getDescriptor(<class to take converter>);
        DirectToFieldMapping mapping = (DirectToFieldMapping)descriptor.getMappingForAttributeName(<mapping to be converted>);
        mapping.addConverter(new YourConverter);
    }
}
[/code]
[Message sent by forum member 'gyorke' (gyorke)]

http://forums.java.net/jive/thread.jspa?messageID=220353