You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Chuangyu <zh...@gmail.com> on 2015/05/15 06:17:11 UTC

query aggregate values

Hi,

I tried to find query  aggregate values use JDOQL ,but
DomainObjectContainer seems not support that?

all methods returns  <T>  or List<T>, but cannot return a Integer.

for example :

@javax.jdo.annotations.Query(
name="countAll",language = "JDOQL",
value = "SELECT count(this)"
+ "FROM dom.SimpleObject"
)


Thanks

James

Re: query aggregate values

Posted by Chuangyu <zh...@gmail.com>.
Erik

Thank you !

I will try this way.

Best Regards,
James


2015-05-18 22:23 GMT+08:00 Erik de Hair <e....@pocos.nl>:

> On 05/18/2015 02:03 PM, Chuangyu wrote:
>
>> Dan,
>> Ok, I will try type-safe queries.
>>
> You could do:
>
> TypesafeQuery<DomainClass> tq = ((JDOPersistenceManager)
> isisJdoSupport.getJdoPersistenceManager()).newTypesafeQuery(DomainClass.class);
> QDomainClass cand = QDomainClass.candidate();
> Long numberOfResults = (Long)tq.executeResultUnique(true, cand.count());
>
> Erik
>
>
>> Thanks for your support.
>>
>> Rgards,
>>
>> James.
>>
>> 2015-05-16 19:23 GMT+08:00 Dan Haywood <da...@haywood-associates.co.uk>:
>>
>>  Another option is to use DataNucleus' type-safe queries.  I just recently
>>> started playing around with these; the isisaddons' todoapp shows an
>>> example
>>> [1]
>>>
>>> The main thing you need to ensure is that your IDE has annotation
>>> processing enabled.  IntelliJ does this automatically, so does Eclipse I
>>> think, so it should probably "just work".  It requires:
>>>
>>>                  <dependency>
>>>                      <groupId>org.datanucleus</groupId>
>>>                      <artifactId>datanucleus-api-jdo</artifactId>
>>>                  </dependency>
>>>
>>> to be in your classpath of the dom module (this is where the annotation
>>> processor implementation is, I believe).
>>>
>>> Cheers
>>> Dan
>>>
>>>
>>> [1]
>>>
>>>
>>> https://github.com/isisaddons/isis-app-todoapp/blob/master/dom/src/main/java/todoapp/dom/module/todoitem/ToDoItemRepositoryImplUsingTypesafeQueries.java#L37
>>>
>>> On 15 May 2015 at 05:28, Chuangyu <zh...@gmail.com> wrote:
>>>
>>>  Oh ,I find the IsisJdoSupportService.
>>>>
>>>> 2015-05-15 12:17 GMT+08:00 Chuangyu <zh...@gmail.com>:
>>>>
>>>>  Hi,
>>>>>
>>>>> I tried to find query  aggregate values use JDOQL ,but
>>>>> DomainObjectContainer seems not support that?
>>>>>
>>>>> all methods returns  <T>  or List<T>, but cannot return a Integer.
>>>>>
>>>>> for example :
>>>>>
>>>>> @javax.jdo.annotations.Query(
>>>>> name="countAll",language = "JDOQL",
>>>>> value = "SELECT count(this)"
>>>>> + "FROM dom.SimpleObject"
>>>>> )
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>> James
>>>>>
>>>>>
>

Re: query aggregate values

Posted by Erik de Hair <e....@pocos.nl>.
On 05/18/2015 02:03 PM, Chuangyu wrote:
> Dan,
> Ok, I will try type-safe queries.
You could do:

TypesafeQuery<DomainClass> tq = ((JDOPersistenceManager) 
isisJdoSupport.getJdoPersistenceManager()).newTypesafeQuery(DomainClass.class);
QDomainClass cand = QDomainClass.candidate();
Long numberOfResults = (Long)tq.executeResultUnique(true, cand.count());

Erik
>
> Thanks for your support.
>
> Rgards,
>
> James.
>
> 2015-05-16 19:23 GMT+08:00 Dan Haywood <da...@haywood-associates.co.uk>:
>
>> Another option is to use DataNucleus' type-safe queries.  I just recently
>> started playing around with these; the isisaddons' todoapp shows an example
>> [1]
>>
>> The main thing you need to ensure is that your IDE has annotation
>> processing enabled.  IntelliJ does this automatically, so does Eclipse I
>> think, so it should probably "just work".  It requires:
>>
>>                  <dependency>
>>                      <groupId>org.datanucleus</groupId>
>>                      <artifactId>datanucleus-api-jdo</artifactId>
>>                  </dependency>
>>
>> to be in your classpath of the dom module (this is where the annotation
>> processor implementation is, I believe).
>>
>> Cheers
>> Dan
>>
>>
>> [1]
>>
>> https://github.com/isisaddons/isis-app-todoapp/blob/master/dom/src/main/java/todoapp/dom/module/todoitem/ToDoItemRepositoryImplUsingTypesafeQueries.java#L37
>>
>> On 15 May 2015 at 05:28, Chuangyu <zh...@gmail.com> wrote:
>>
>>> Oh ,I find the IsisJdoSupportService.
>>>
>>> 2015-05-15 12:17 GMT+08:00 Chuangyu <zh...@gmail.com>:
>>>
>>>> Hi,
>>>>
>>>> I tried to find query  aggregate values use JDOQL ,but
>>>> DomainObjectContainer seems not support that?
>>>>
>>>> all methods returns  <T>  or List<T>, but cannot return a Integer.
>>>>
>>>> for example :
>>>>
>>>> @javax.jdo.annotations.Query(
>>>> name="countAll",language = "JDOQL",
>>>> value = "SELECT count(this)"
>>>> + "FROM dom.SimpleObject"
>>>> )
>>>>
>>>>
>>>> Thanks
>>>>
>>>> James
>>>>


Re: query aggregate values

Posted by Chuangyu <zh...@gmail.com>.
Dan,
Ok, I will try type-safe queries.

Thanks for your support.

Rgards,

James.

2015-05-16 19:23 GMT+08:00 Dan Haywood <da...@haywood-associates.co.uk>:

> Another option is to use DataNucleus' type-safe queries.  I just recently
> started playing around with these; the isisaddons' todoapp shows an example
> [1]
>
> The main thing you need to ensure is that your IDE has annotation
> processing enabled.  IntelliJ does this automatically, so does Eclipse I
> think, so it should probably "just work".  It requires:
>
>                 <dependency>
>                     <groupId>org.datanucleus</groupId>
>                     <artifactId>datanucleus-api-jdo</artifactId>
>                 </dependency>
>
> to be in your classpath of the dom module (this is where the annotation
> processor implementation is, I believe).
>
> Cheers
> Dan
>
>
> [1]
>
> https://github.com/isisaddons/isis-app-todoapp/blob/master/dom/src/main/java/todoapp/dom/module/todoitem/ToDoItemRepositoryImplUsingTypesafeQueries.java#L37
>
> On 15 May 2015 at 05:28, Chuangyu <zh...@gmail.com> wrote:
>
> > Oh ,I find the IsisJdoSupportService.
> >
> > 2015-05-15 12:17 GMT+08:00 Chuangyu <zh...@gmail.com>:
> >
> > > Hi,
> > >
> > > I tried to find query  aggregate values use JDOQL ,but
> > > DomainObjectContainer seems not support that?
> > >
> > > all methods returns  <T>  or List<T>, but cannot return a Integer.
> > >
> > > for example :
> > >
> > > @javax.jdo.annotations.Query(
> > > name="countAll",language = "JDOQL",
> > > value = "SELECT count(this)"
> > > + "FROM dom.SimpleObject"
> > > )
> > >
> > >
> > > Thanks
> > >
> > > James
> > >
> >
>

Re: query aggregate values

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Another option is to use DataNucleus' type-safe queries.  I just recently
started playing around with these; the isisaddons' todoapp shows an example
[1]

The main thing you need to ensure is that your IDE has annotation
processing enabled.  IntelliJ does this automatically, so does Eclipse I
think, so it should probably "just work".  It requires:

                <dependency>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>datanucleus-api-jdo</artifactId>
                </dependency>

to be in your classpath of the dom module (this is where the annotation
processor implementation is, I believe).

Cheers
Dan


[1]
https://github.com/isisaddons/isis-app-todoapp/blob/master/dom/src/main/java/todoapp/dom/module/todoitem/ToDoItemRepositoryImplUsingTypesafeQueries.java#L37

On 15 May 2015 at 05:28, Chuangyu <zh...@gmail.com> wrote:

> Oh ,I find the IsisJdoSupportService.
>
> 2015-05-15 12:17 GMT+08:00 Chuangyu <zh...@gmail.com>:
>
> > Hi,
> >
> > I tried to find query  aggregate values use JDOQL ,but
> > DomainObjectContainer seems not support that?
> >
> > all methods returns  <T>  or List<T>, but cannot return a Integer.
> >
> > for example :
> >
> > @javax.jdo.annotations.Query(
> > name="countAll",language = "JDOQL",
> > value = "SELECT count(this)"
> > + "FROM dom.SimpleObject"
> > )
> >
> >
> > Thanks
> >
> > James
> >
>

Re: query aggregate values

Posted by Chuangyu <zh...@gmail.com>.
Oh ,I find the IsisJdoSupportService.

2015-05-15 12:17 GMT+08:00 Chuangyu <zh...@gmail.com>:

> Hi,
>
> I tried to find query  aggregate values use JDOQL ,but
> DomainObjectContainer seems not support that?
>
> all methods returns  <T>  or List<T>, but cannot return a Integer.
>
> for example :
>
> @javax.jdo.annotations.Query(
> name="countAll",language = "JDOQL",
> value = "SELECT count(this)"
> + "FROM dom.SimpleObject"
> )
>
>
> Thanks
>
> James
>