In a Grails application, you'd create a domain class for each.
在Grails应用程序中,要为每个元素创建一个域类。
Every domain class pairs up with a controller based on the name.
每个域类根据名称与一个控制器配对。
In this case, the feature and county columns aren't represented in the domain class.
在这种情况下,feature与county列未表示在域类中。
Grails looks for the constraints declarations in the same directory as our domain class.
Grails在领域类相同的目录下查找约束声明。
That way every new domain class created already has the fields and event closures in place.
这样,新创建域类时它们就有适当的字段和事件闭包。
You should see the files added (both the domain class and the corresponding integration test).
此时应该看到添加的文件(域类和对应的集成测试)。
As you can see, the unit test for a domain class now (with Grails 1.1) extends GrailsUnitTestCase.
可以看到,现在对一个域类的单元测试(在Grails 1.1中)扩展了GrailsUnitTestCase。
Using auto completion is a fast way to remember what queries are available for a certain domain class.
使用自动完成是记住什么查询可用于特定域类的快捷方法。
This is where you can put the static constraints block that would normally be in the domain class.
该文件中可以放置本应该位于域类中的静态constraints块。
Grails gives you a place to store commonly used methods that transcend any single domain class: services.
Grails为您提供了保存常用方法的位置,并且超越了任何单个的域类:即服务。
Looking back at the source code of the User domain class in Listing 1, clearly no validate method is defined.
回头看一下清单1中user域类的源代码,很明显其中没有定义任何validate方法。
In this version, the domain class (in yellow) includes an interface that defines the semantics of a schedule item.
在此版本中,域类(黄色部分)包含了一个定义日程项目语义的界面。
In the subsequent articles, I made changes to the domain class and never had you go back and regenerate the views.
在随后的文章中,我更改了domain类,但是从未让您再回过头来生成视图。
Note that the GenericDaoHibernateImpl class defines only one constructor that takes a domain class as its argument.
注意,GenericDaoHibernateImpl类仅定义一个构造函数,该构造函数接受域类作为其参数。
For the purposes of this discussion, I prefix all query names with the short (unqualified) name of the domain class.
出于讨论目的,我为所有查询名称都加了域类的短(非限定)名称作为前缀。
The first strategy I'll demonstrate for mapping your domain class to a legacy table is using a static mapping block.
我将示范的第一个将域类映射到遗留表的策略是使用静态mapping块。
This means that every time you create, update, or delete a domain class, the Lucene index is updated accordingly.
这就意味着每当您创建、更新或删除一个domain类时,Lucene索引都会相应更新。
Theses clone classes must have the same name than the Domain class (in a different package) and inherits from LazyGwtPojo.
这些克隆类必须使用和域类本身一样的名字(但两者在不同的包中),并且继承LazyGwtPojo。
For example, when you save a domain class to a mock table, the id field is populated as it would be in a live application.
例如,当您将一个域类保存到模拟表在中时,会像在实际应用程序中一样填充id字段。
In addition to timestamping your domain class, you can tap into four event hooks: beforeInsert, befortUpdate, beforeDelete, and onLoad.
除了给域类添加时间戳,还可以引入4 个事件挂钩:beforeInsert、befortUpdate、beforeDelete和onload。
This method instructs Grails to metaprogram the validation methods onto the specified domain class as it would normally during run time.
此方法指示Grails将验证方法元编程到指定的域类上,就像通常在运行时所做的一样。
This time, however, the failure isn't due to the lack of metaprogramming on a domain class. It's due to the lack of dependency injection.
但是,这次失败并不是因为域类上缺少元编程,而是因为缺少依赖性注入。
Or do you move all the validation code into the services tier, removing it from the domain class that should be the owner of that knowledge?
或者您可以将所有验证代码移入到服务层,然后从应当是该知识所有者的域类中删除它吗?
Because this bean definition is abstract, I can reuse the definition a number of times later and set the constructor argument to a suitable domain class.
因为该bean定义是抽象的,所以我将来可以无数次地重用该定义,并将构造函数参数设置为合适的域类。
We want Grails to recognize these classes as our domain classes and to provide all the ORM and dynamic method goodness that comes with a Grails domain class.
我们要让Grails将这些类认为是我们的领域类,并提供Grails领域类所拥有的ORM和动态方法的全部好处。
By convention, Grails looks for a script with the same name as your domain class but ending with the word "Constraints" (e.g., EmployeeBeanConstraints.groovy).
根据惯例,Grails以领域类名+“Constraints”为名字(如employeebeanconstraints .groovy),去查找脚本。
But if you picked a specific domain class (say the Customer class) and tested the error handling aspect against it, you would risk muddying the intent of your test.
但是如果选择了特定的域类(比如customer类),并测试了它的错误处理方面,那么就会有模糊测试目的的可能性。
Instead, an interface defines the semantics for both your domain class and the ScheduleItemForm class, which ACTS as a bridge between your domain and the framework.
相反,一个接口为您的域类和ScheduleItemFor m类定义了语义,后者充当域类与框架之间的一个桥梁。
The domain class properly has a transaction attribute of MANDATORY because the client is starting the transaction, and the domain model (insertTrade()) is not responsible for rollback.
域类属性有一个事务属性MANDATORY,因为客户机正在启动事务,而域模型(insertTrade())不负责执行回滚。
In this section, we show how to update the domain validator class to validate a set of units in a diagram.
在这一部分之中,我们向您展示了怎样更新域确认器类,以确认图表之中的一系列单元。
应用推荐