简体   繁体   中英

domain class in grails

please help me

I have this class

Class Person
{
 String name
 String id
 Date date
}

This class is connected with mysql

my question is where put this:

Person.count() or Person.findByAllName("Carlos")

Class Person
{
 String name
 String id
 Date date
def person = Person.count() //here???
}

I want to create a field person that show how many register have the table.

is possible with scaffold only, because have error the moment of run app?

Thanks and sorry by my bad english¡¡¡

The correct place would be outside the domain class. Also, you need not define the Id on the domain class, as it is autogenerated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM