You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Craig Taylor <ct...@ctalkobt.net> on 2014/02/18 20:48:20 UTC

OpenJpa 2.2.0 - Literal is not truly literal when generating sql.

It appears the the criteriaBuilder.literal() is not treated as literal
consistently during generation of HQL / SQL.

For criteria queries, the HQL (OpenJPAQuery.getQueryString())  is generated
as what I would consider proper HQL in that parameters are :prefixed and
literals are hard valued within the query. eg: (SELECT sample, sample2 FROM
table WHERE sample=:parameter AND sample2='literal value'; )

When the sql is generated however, both via :
OpenJPAQuery.getDataStoreActions(parm)[0] the paramaters (other than data
parameters) are directly substituted (eg: SELECT sample, sample2 FROM table
WHERE sample='paramter value' AND sample2='literal')

When the query is actually performed however, via logging I see that
everything is treated as a parameter. (SELECT sample, sample2 FROM table
WHERE sample=:parameter AND sample2=:sample2 ).

This is an issue as when dealing with partitioned tables Postgres is unable
to perform a valid query plan without the associated values on the column
that we have partitioned on.   Running this from within OpenJPA 2.2.0 and
OpenJPA 2.2.2 yield the same results.   I believe that this is an attempt
to help the database cache query plans yet this optimization is actually
causing a major performance problem.

Suggestions?

-- 
-------------------------------------------
Craig Taylor
ctalkobt@ctalkobt.net

Re: OpenJpa 2.2.0 - Literal is not truly literal when generating sql.

Posted by Craig Taylor <ct...@ctalkobt.net>.
Confirmed. Thanks.


On Tue, Feb 18, 2014 at 2:58 PM, Rick Curtis <cu...@gmail.com> wrote:

> Craig -
>
> It looks like OPENJPA-2324[1] might be what you are looking for?
>
> Heath -- Any chance that we can get some documentation for this change?
>
> [1] https://issues.apache.org/jira/browse/OPENJPA-2324
>
> Thanks,
> Rick
>
>
> On Tue, Feb 18, 2014 at 1:48 PM, Craig Taylor <ct...@ctalkobt.net>
> wrote:
>
> > It appears the the criteriaBuilder.literal() is not treated as literal
> > consistently during generation of HQL / SQL.
> >
> > For criteria queries, the HQL (OpenJPAQuery.getQueryString())  is
> generated
> > as what I would consider proper HQL in that parameters are :prefixed and
> > literals are hard valued within the query. eg: (SELECT sample, sample2
> FROM
> > table WHERE sample=:parameter AND sample2='literal value'; )
> >
> > When the sql is generated however, both via :
> > OpenJPAQuery.getDataStoreActions(parm)[0] the paramaters (other than data
> > parameters) are directly substituted (eg: SELECT sample, sample2 FROM
> table
> > WHERE sample='paramter value' AND sample2='literal')
> >
> > When the query is actually performed however, via logging I see that
> > everything is treated as a parameter. (SELECT sample, sample2 FROM table
> > WHERE sample=:parameter AND sample2=:sample2 ).
> >
> > This is an issue as when dealing with partitioned tables Postgres is
> unable
> > to perform a valid query plan without the associated values on the column
> > that we have partitioned on.   Running this from within OpenJPA 2.2.0 and
> > OpenJPA 2.2.2 yield the same results.   I believe that this is an attempt
> > to help the database cache query plans yet this optimization is actually
> > causing a major performance problem.
> >
> > Suggestions?
> >
> > --
> > -------------------------------------------
> > Craig Taylor
> > ctalkobt@ctalkobt.net
> >
>
>
>
> --
> *Rick Curtis*
>



-- 
-------------------------------------------
Craig Taylor
ctalkobt@ctalkobt.net

Re: OpenJpa 2.2.0 - Literal is not truly literal when generating sql.

Posted by Rick Curtis <cu...@gmail.com>.
Craig -

It looks like OPENJPA-2324[1] might be what you are looking for?

Heath -- Any chance that we can get some documentation for this change?

[1] https://issues.apache.org/jira/browse/OPENJPA-2324

Thanks,
Rick


On Tue, Feb 18, 2014 at 1:48 PM, Craig Taylor <ct...@ctalkobt.net> wrote:

> It appears the the criteriaBuilder.literal() is not treated as literal
> consistently during generation of HQL / SQL.
>
> For criteria queries, the HQL (OpenJPAQuery.getQueryString())  is generated
> as what I would consider proper HQL in that parameters are :prefixed and
> literals are hard valued within the query. eg: (SELECT sample, sample2 FROM
> table WHERE sample=:parameter AND sample2='literal value'; )
>
> When the sql is generated however, both via :
> OpenJPAQuery.getDataStoreActions(parm)[0] the paramaters (other than data
> parameters) are directly substituted (eg: SELECT sample, sample2 FROM table
> WHERE sample='paramter value' AND sample2='literal')
>
> When the query is actually performed however, via logging I see that
> everything is treated as a parameter. (SELECT sample, sample2 FROM table
> WHERE sample=:parameter AND sample2=:sample2 ).
>
> This is an issue as when dealing with partitioned tables Postgres is unable
> to perform a valid query plan without the associated values on the column
> that we have partitioned on.   Running this from within OpenJPA 2.2.0 and
> OpenJPA 2.2.2 yield the same results.   I believe that this is an attempt
> to help the database cache query plans yet this optimization is actually
> causing a major performance problem.
>
> Suggestions?
>
> --
> -------------------------------------------
> Craig Taylor
> ctalkobt@ctalkobt.net
>



-- 
*Rick Curtis*