You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by creinke <cr...@ford.com> on 2015/12/21 13:34:19 UTC

Documentation - Delta Spike Data - Incorrect JP QL Query Examples

There are several places in the documentation where you use what appears to
be an incorrect JP QL query (see example below).  I tested these queries in
a sample project that we developed and they don’t work, nor do they seem to
make sense (take a look below) since query using the "count" option will
return a Long and the "order by" option a List.  To make it work as
appropriate for what was documented, we dropped the “order by p.age asc”
clause in all our sample project test cases.  I believe you will need to fix
those queries in the documentation as appropriate to be correct.  Incorrect
Query (only one of several places where this query was used):
-----------------------------------------------------------------------@NamedQuery(name
= Person.BY_MIN_AGE,    query = "select count(p) from Person p where p.age >
:minAge order by p.age asc")One corrected version: 
----------------------@Testpublic void
testCountAllOlderThanUsingNamedQuery() {       final int minAge = 32;      
final Long count =
personRepository.countAllOlderThanUsingNamedQuery(minAge);      
assertTrue(count > 0);              System.out.println("Using a Named @Query
annotation: named = PersonDE.BY_MIN_AGE");       System.out.println("   
There are " + count + " people in database older than " +
minAge);}@NamedQuery(name = PersonDE.COUNT_BY_MIN_AGE,       query = "select
count(p) from PersonDE p where p.age > ?1"),



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/Documentation-Delta-Spike-Data-Incorrect-JP-QL-Query-Examples-tp4661946.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: Documentation - Delta Spike Data - Incorrect JP QL Query Examples

Posted by Gerhard Petracek <ge...@gmail.com>.
hi,

please create a jira-ticket.
i'll assign it to thomas.

thx & regards,
gerhard



2015-12-21 13:34 GMT+01:00 creinke <cr...@ford.com>:

> There are several places in the documentation where you use what appears to
> be an incorrect JP QL query (see example below).  I tested these queries in
> a sample project that we developed and they don’t work, nor do they seem to
> make sense (take a look below) since query using the "count" option will
> return a Long and the "order by" option a List.  To make it work as
> appropriate for what was documented, we dropped the “order by p.age asc”
> clause in all our sample project test cases.  I believe you will need to
> fix
> those queries in the documentation as appropriate to be correct.  Incorrect
> Query (only one of several places where this query was used):
>
> -----------------------------------------------------------------------@NamedQuery(name
> = Person.BY_MIN_AGE,    query = "select count(p) from Person p where p.age
> >
> :minAge order by p.age asc")One corrected version:
> ----------------------@Testpublic void
> testCountAllOlderThanUsingNamedQuery() {       final int minAge = 32;
> final Long count =
> personRepository.countAllOlderThanUsingNamedQuery(minAge);
> assertTrue(count > 0);              System.out.println("Using a Named
> @Query
> annotation: named = PersonDE.BY_MIN_AGE");       System.out.println("
> There are " + count + " people in database older than " +
> minAge);}@NamedQuery(name = PersonDE.COUNT_BY_MIN_AGE,       query =
> "select
> count(p) from PersonDE p where p.age > ?1"),
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/Documentation-Delta-Spike-Data-Incorrect-JP-QL-Query-Examples-tp4661946.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>