users@jpa-spec.java.net

[jpa-spec users] Re: mapping conversion

From: Oliver Gierke <ogierke_at_vmware.com>
Date: Fri, 13 Jan 2012 02:44:14 -0800

Hi all,

comments inline

Am 12.01.2012 um 01:49 schrieb Linda DeMichiel:

>>> The @Convert annotation may be used on default or explicitly mapped basic attributes. It is not portably supported to
>>> use @Convert on mappings marked with @Enumerated, @Temporal, @Id, @Version or on embedded, relationship or element
>>> collection attributes.

Why shouldn't it be allowed for embeddables?

>>> XML
>>>
>>> Converters can be defined in XML at method, class, mapping file or persistence unit level, similar to generators, and
>>> will override the same named converters if such converters were defined in annotation form.

Does this mean the converters would be instantiated by the persistence provider then? This would expose it to the same drawbacks EntityListeners currently face: injecting objects into them is quite complicated.

Is there some notion of a "global converter"? Given Mike's examples one would have to annotate each and every boolean attribute in entity classes with @Convert("booleanToInteger") to get it converted. What if the converters registered would be applied globally to all attributes of the appropriate type (discoverable from generics) and could be explicitly overridden at the field level. Alternatively we could have a "global" flag in the @Converter annotation that triggers this behavior.

Regards,
Ollie

-- 
/**
* @author Oliver Gierke - Senior Member Technical Staff
*
* @param email ogierke_at_vmware.com
* @param phone +49-351-30929001
* @param fax   +49-351-418898439
* @param skype einsdreizehn
* @see http://www.olivergierke.de
*/