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

Mark Struberg commented on OPENJPA-2341:
----------------------------------------

While tinkering a unit test I came across another weird issue. The custom 
ValueHandlers are totally ignored if the field is not a BASIC column. For 
_some_ types like joda's LocalDate it works 'by accident' as LocalDate is 
java.io.Serializable and thus gets detected as 'persistable' by OpenJPA (under 
FieldStrategy BASIC). 

We need to change this detection and also handle fields which have an explicit 
ValueHandler or PersistenceStrategy assigned.
This is not only important for the MetaData factory at runtime but also for all 
kind of enhancements, esp compile-time and javaagent enhancement!

> OpenJPA ignores custom field strategies globally defined in persistence.xml
> ---------------------------------------------------------------------------
>
>                 Key: OPENJPA-2341
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2341
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.2.0
>            Reporter: Michael Rüegg
>            Assignee: Mark Struberg
>            Priority: Blocker
>         Attachments: OPENJPA-2341.patch
>
>
> I use a custom field strategy value handler (a class that extends 
> org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler) for my entities 
> that make use of joda time fields:
> @Entity
> public class MyEntity {
>   org.joda.time.LocalDateTime creationDate;
> }
> When I use the inline strategy annotation 
> (@Strategy("com.xyz.LocalDateValueHandler")), everything works as expected 
> and my LocalDateTime field 'creationDate' gets mapped to an SQL timestamp. 
> However, if I reference my value handler globally in the persistence.xml 
> file, then OpenJPA is not able to find the value handler (i.e., it is never 
> called), which results in a blob column type for 'creationDate'. Here's the 
> corresponding snippet from my persistence.xml:
> <property name="openjpa.jdbc.MappingDefaults" 
> value="FieldStrategies='org.joda.time.LocalDateTime=com.xyz.LocalDateValueHandler"/>
> Note that if I use a mapping from a standard JDK class like java.lang.String 
> to my value handler, then my handler is called as expected. Is this issue 
> somehow related to #OPENJPA-758? Note that I use Derby as my database.
> Any help would be much appreciated.



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

Reply via email to