You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Gary Jarrel <ga...@gmail.com> on 2006/10/27 13:20:07 UTC

Last Record

Hey All!

Just looking for some advice on getting the last record out of a
table, hoping for the most efficient solution.

For example user table has a open to many into a login_history table,
when a user logs in I want to get the last record out of a
login_history table based on the login_date field for this particular
user. I'm trying to avoid getting the entire login history into a
list, and then retrieving the last record in this list (sorted
ofcourse)

Any best practices under Cayenne?

Thanks in advance.

Gary

Re: Re: Last Record

Posted by Michael Gentry <bl...@gmail.com>.
I was thinking just use an SQLTemplate and fetch the last PK and then
fault it in.

/dev/mrg


On 10/27/06, Matt Kerr <ma...@centralparksoftware.com> wrote:
> This is from the hip - so add salt ..
>
> but how about sort descending and use a fetchLimit = 1
> (does that make sense?)
>
> ok - thanks,
> -mk
>
> On Oct 27, 2006, at 04:20 , Gary Jarrel wrote:
>
> > Hey All!
> >
> > Just looking for some advice on getting the last record out of a
> > table, hoping for the most efficient solution.
> >
> > For example user table has a open to many into a login_history table,
> > when a user logs in I want to get the last record out of a
> > login_history table based on the login_date field for this particular
> > user. I'm trying to avoid getting the entire login history into a
> > list, and then retrieving the last record in this list (sorted
> > ofcourse)
> >
> > Any best practices under Cayenne?
> >
> > Thanks in advance.
> >
> > Gary
>
>

Re: Last Record

Posted by Matt Kerr <ma...@centralparksoftware.com>.
This is from the hip - so add salt ..

but how about sort descending and use a fetchLimit = 1
(does that make sense?)

ok - thanks,
-mk

On Oct 27, 2006, at 04:20 , Gary Jarrel wrote:

> Hey All!
>
> Just looking for some advice on getting the last record out of a
> table, hoping for the most efficient solution.
>
> For example user table has a open to many into a login_history table,
> when a user logs in I want to get the last record out of a
> login_history table based on the login_date field for this particular
> user. I'm trying to avoid getting the entire login history into a
> list, and then retrieving the last record in this list (sorted
> ofcourse)
>
> Any best practices under Cayenne?
>
> Thanks in advance.
>
> Gary