简体   繁体   English

Grails中的域类

[英]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 此类与mysql连接

my question is where put this: 我的问题是放在哪里:

Person.count() or Person.findByAllName("Carlos") Person.count()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 另外,您无需在域类上定义ID,因为它是自动生成的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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