to get the last record from db

View: New views
3 Messages — Rating Filter:   Alert me  

to get the last record from db

by Gayathirya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi ,
I'm trying to get the last record from db using createCriteria

the code below in controler class
            def criteria = Status.createCriteria()
            int count = criteria.get{
                projections{
                    max("id")
                }
            }

            def showresults = Status.get(count)


it's putting runtime errors like this

Error 500: groovy.lang.MissingPropertyException: No such property: projections for class: grails.orm.HibernateCriteriaBuilder
Servlet: grails
URI: /HSMC/grails/secure.dispatch
Exception Message: No such property: projections for class: grails.orm.HibernateCriteriaBuilder
Caused by: groovy.lang.MissingPropertyException: No such property: projections for class: grails.orm.HibernateCriteriaBuilder
Class: GrailsAuthenticationProcessingFilter
At Line: [56]
Code Snippet:

Can anybody help me please..
It's kind of urgent

Re: to get the last record from db

by Robert Fischer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using GORM Labs:

def showresults = Status.get(Status.maxId)

Whatever you're doing with querying the maximum id, though, it's probably wrong.

~~ Robert Fischer, Smokejumper IT Consulting.
Enfranchised Mind Blog http://EnfranchisedMind.com/blog

Grails Expert Retainer Services
http://smokejumperit.com/grails-retainer/


Gayathirya wrote:

> Hi ,
> I'm trying to get the last record from db using createCriteria
>
> the code below in controler class
>             def criteria = Status.createCriteria()
>             int count = criteria.get{
>                 projections{
>                     max("id")
>                 }
>             }
>
>             def showresults = Status.get(count)
>
>
> it's putting runtime errors like this
>
> Error 500: groovy.lang.MissingPropertyException: No such property:
> projections for class: grails.orm.HibernateCriteriaBuilder
> Servlet: grails
> URI: /HSMC/grails/secure.dispatch
> Exception Message: No such property: projections for class:
> grails.orm.HibernateCriteriaBuilder
> Caused by: groovy.lang.MissingPropertyException: No such property:
> projections for class: grails.orm.HibernateCriteriaBuilder
> Class: GrailsAuthenticationProcessingFilter
> At Line: [56]
> Code Snippet:
>
> Can anybody help me please..
> It's kind of urgent

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: to get the last record from db

by Gayathirya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Robert,
Thanks for the reply.
But my method also working fine  .
previously i added some extra line Because of that only there were some errors.

Previously i tried somewhat similar as you suggested that is not working.


Robert Fischer wrote:
Using GORM Labs:

def showresults = Status.get(Status.maxId)

Whatever you're doing with querying the maximum id, though, it's probably wrong.

~~ Robert Fischer, Smokejumper IT Consulting.
Enfranchised Mind Blog http://EnfranchisedMind.com/blog

Grails Expert Retainer Services
http://smokejumperit.com/grails-retainer/


Gayathirya wrote:
> Hi ,
> I'm trying to get the last record from db using createCriteria
>
> the code below in controler class
>             def criteria = Status.createCriteria()
>             int count = criteria.get{
>                 projections{
>                     max("id")
>                 }
>             }
>
>             def showresults = Status.get(count)
>
>
> it's putting runtime errors like this
>
> Error 500: groovy.lang.MissingPropertyException: No such property:
> projections for class: grails.orm.HibernateCriteriaBuilder
> Servlet: grails
> URI: /HSMC/grails/secure.dispatch
> Exception Message: No such property: projections for class:
> grails.orm.HibernateCriteriaBuilder
> Caused by: groovy.lang.MissingPropertyException: No such property:
> projections for class: grails.orm.HibernateCriteriaBuilder
> Class: GrailsAuthenticationProcessingFilter
> At Line: [56]
> Code Snippet:
>
> Can anybody help me please..
> It's kind of urgent

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email