openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Is this possible with CriteriaBuilder method
Date Wed, 20 Apr 2011 13:52:36 GMT
Hi Pinaki,
Can you demonstrate how the "@rownum" user variable could be utilized in
CriteriaBuilder?

SELECT @rownum:=@rownum+1 'no', m.title, m.author,
REPLACE(SUBSTRING_INDEX(m.
content, ' ', 20), '<br>', ' '), m.viewed,
m.hashid FROM book m, (SELECT @rownum:=0) r WHERE m.lang = ?1 AND m.title
like CONCAT('%',?2,'%') ORDER BY m.title asc

I looked through your article and the spec, and couldn't find how to use
this idea.

Thanks,
Kevin


On Wed, Apr 20, 2011 at 3:30 AM, Pinaki Poddar <ppoddar@apache.org> wrote:

> Hi,
>   > Can I convert this native MySQL query using purely the CriteriaBuilder
> method:
>   Yes, you can.
>
>  Your question points to an important feature of Criteria query that is
> distinct from string-based JPQL query. Criteria query API makes this
> distinction via CriteriaBuilder.function() method -- that will allow you to
> use database functions in your query.
>
>
>  Similar expression is not possible to express with JPQL query that use a
> fixed grammar.
>
>  See usage of CriteriaBuilder.function() method.
>  Or refer to this article [1] which has few examples of this method in its
> 'Advanced Features' section.
>
>
> [1] http://www.ibm.com/developerworks/java/library/j-typesafejpa/
>
> -----
> Pinaki
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Is-this-possible-with-CriteriaBuilder-method-tp6283183p6289977.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message