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

ASF subversion and git services commented on OPENJPA-2861:
----------------------------------------------------------

Commit 813154a570797b35a0c5d0469817775cd58ae525 in openjpa's branch 
refs/heads/master from Mark Struberg
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=813154a ]

OPENJPA-2861 fix unit test

Boolean is the correct return value.
This should actually have been returned for all dictionaries.
The problem is that we always only return the _internal_ representation.
The reason is because CASE/WHEN can be used to return values, but also as 
subquery.
Now imagine a database uses 0 and 1 for false and true. If CASE/WHEN is used
as subquery we really have to return 0/1 (number) because otherwise the WHERE 
clause
would not fit. When not executing the query on a Entity, we do not know the 
target type.
So there is probably no way we can later do a BooleanRepresentation call to 
switch to boolean.
And this would also break existing applications.


> select sum(CASE x WHEN x THEN 1 ELSE 0 ) returns String instead of Long.
> ------------------------------------------------------------------------
>
>                 Key: OPENJPA-2861
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2861
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 3.1.2
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>            Priority: Major
>             Fix For: 3.2.0
>
>
> It seems that a few operations in {{JDBCExpressionFactory}} often calls 
> {{getLiteralRawString}} which destroys the information about any real types 
> in a query and replaces it with a {{Raw}} which is always of type 
> {{java.lang.String}}.
> This breaks the following query, which wrongly returns a string instead of a 
> Long:
> {noformat}
> final TypedQuery<Long> q 
>    = em.createQuery("select SUM(CASE ae.stringVal WHEN 'bare' THEN 1 ELSE 0 
> END) from AggEntity AS ae", Long.class);
> final Long sumC = q.getSingleResult();{noformat}
> This only affects us since I fixed {{UnaryOp}} to not return the native JDBC 
> vendor type of a given column but uses the {{val.getType()}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to