[ 
https://issues.apache.org/jira/browse/JDO-709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14565853#comment-14565853
 ] 

Andy Jefferson commented on JDO-709:
------------------------------------

> @Andy: "If we [default the useDefaultConversion to] "false" then that implies 
> it will need a provided converter."
> I think the only confusion is in case 1 where it may sound like both "use 
> default converter class" and "don't use default conversion". 
> Which is the confusion between annotation default and default behavior. 

Indeed. It is misleading. The "converter" attribute default says use the 
"default conversion", whilst the boolean "useDefaultConversion" says DON'T use 
the "default conversion".

> At runtime, I don't think the template types are available, as they have been 
> erased. 
> How does the implementation figure out the A and D of AttributeConverter<A, 
> D>? Do we need to add ...

The code at 
https://github.com/datanucleus/datanucleus-api-jdo/blob/master/src/main/java/org/datanucleus/api/jdo/JDOTypeConverterUtils.java
works fine for cases I've used. For example if I have a converter

public class CurrencyAttrConverter implements AttributeConverter<Currency, 
String>
{
    public Currency convertToAttribute(String str)
    {
        if (str == null)
        {
            return null;
        }
        return java.util.Currency.getInstance(str.substring(5));
    }

    public String convertToDatastore(Currency curr)
    {
        return curr != null ? ("CURR:" + curr.toString()) : null;
    }
}

then use of those methods returns the attribute type as Currency, and the 
dbType as String.

> Standardize field/property converters
> -------------------------------------
>
>                 Key: JDO-709
>                 URL: https://issues.apache.org/jira/browse/JDO-709
>             Project: JDO
>          Issue Type: New Feature
>          Components: api
>            Reporter: Matthew T. Adams
>            Assignee: Matthew T. Adams
>            Priority: Minor
>              Labels: converstion, converter, jdo, type, type-converter
>             Fix For: JDO 3.2
>
>         Attachments: JDO-709-01.patch, JDO-709-3.patch, JDO-709-4.patch
>
>
> This request is to standardize a user's ability to specify conversions of 
> fields or properties of persistence-capable classes.  Currently, this is left 
> to vendor extensions.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to