openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <>
Subject [jira] Assigned: (OPENJPA-586) Binding Query parameter fails validation for Externalized field
Date Mon, 09 Jun 2008 21:49:45 GMT


Pinaki Poddar reassigned OPENJPA-586:

    Assignee: Pinaki Poddar

> Binding Query parameter fails validation for Externalized field
> ---------------------------------------------------------------
>                 Key: OPENJPA-586
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Pinaki Poddar
>            Assignee: Pinaki Poddar
>         Attachments: patch-586.1.txt
> OpenJPA supports a field f of declared type <T> be persisted in database corresponding
to a different type <S> when  f specifies a two-way transformation between <S>
and <T>. For example, a field f can be declared as but stored in database
as String (i.e. VARCHAR). 
> Now the question is:
>     When an 'externalized' field f occurs in query predicate and is bound by a parameter
p what should be the runtime type of p? 
>    The documentation [1] says p can be of either <T> or <S>.
> But the code breaks during parameter validation if Class(p) = <T> and with data
conversion error if Class(p) = <S>
> Example:
> 1.   Declare a persistent field f of type java.util.UUID externalized to java.lang.String
with a pair of transformer functions
>     @Persistent
>     @Externalizer("toString")        
>     @Factory("UUID.fromString")
>     private UUID    uuid;
> 2. Use the field f in a Query with a binding parameter:
>         String jpql = "SELECT p FROM ExternalValues p WHERE p.uuid=:uuid";
>         Query query = em.createQuery(jpql);
> 3. Try to set parameter on the query:
>          a) query.setParameter("uuid", new UUID(1,2));  // parameter type equals declared
type of f
> or
>          b) query.setParameter(1, new UUID(1,2).toString()); // parameter type equals
externalized type of f
> 4. Either of step 3a or 3b will result in runtime exception
> [1]

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message