Hi Jan,
Looks like what you need is a SQLTemplate query:
http://cayenne.apache.org/doc/sqltemplate-query.html
Here is a mockup code example:
SQLTemplate q = new SQLTemplate(SomeClass.class, "select MAX(id)
from table");
q.setFetchingDataRows(true);
Map row = (Map) DataObjectUtils.objectForQuery(q);
Number id = (Number) row.values().iterator().next();
(Cayenne 3.0 will be featuring more elegant API to achieve that, but
still the code above should work just as well)
Andrus
On Oct 9, 2007, at 5:09 PM, jan.stobb..bs.com wrote:
> I am trying to do the following
>
>
>
> select MAX(id) from table. This is part of the recovery logic for a
> program that runs for several days (5). In the event of a failure the
> program attempts to recover its internal state upon restart by
> reading a
> checkpoint file and then applying any database activity that has
> occurred since the checkpoint to its internal state and then resuming
> processing.
>
>
>
> I noticed that there was post by Andrus in response to a similar
> question in one of the issue posts. The suggestion was to use a
> java.apache.cayenne.access.jdbc. SQLSelectStatement. From the
> documentation, I can't quite see how to run a SQlSelectStatement. Any
> assistance or alternatives would be appreciated.
>
>
>
> Regards,
>
>
>
> Jan Stobbe
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Please do not transmit orders or instructions regarding a UBS
> account by e-mail. The information provided in this e-mail or any
> attachments is not an official transaction confirmation or account
> statement. For your protection, do not include account numbers,
> Social Security numbers, credit card numbers, passwords or other
> non-public information in your e-mail. Because the information
> contained in this message may be privileged, confidential,
> proprietary or otherwise protected from disclosure, please notify
> us immediately by replying to this message and deleting it from
> your computer if you have received this communication in error.
> Thank you.
>
>
>
> UBS Financial Services Inc.
>
> UBS International Inc.
>
> UBS Financial Services Incorporated of Puerto Rico
This archive was generated by hypermail 2.0.0 : Tue Oct 09 2007 - 12:24:59 EDT