English 中文(简体)
地图域级,有预先确定的价值,可列出
原标题:Map domain class with predifined values to table

能否建立域级,以绘制地图,列出预先确定的价值,例如:

id value

1个P-4,1个P-3,1个P-2

2 test2

3 试验

或者,我必须用人工处理生成的ed,以弥补这一缺陷。

提前感谢。

最佳回答

表格中固定的一组预先定义的行文是将其填入<代码>。 BootS Screen.groovy 。 例如:

def init = { servletContext ->
    if (MyDomain.count() == 0) {
        new MyDomain(id: 1, value:  test1 ).save(failOnError: true)
        new MyDomain(id: 2, value:  test2 ).save(failOnError: true)
        new MyDomain(id: 3, value:  test3 ).save(failOnError: true)
    }
}

另一种做法是利用移民的gin,并建立一个数据库迁移,以填表。

问题回答

暂无回答




相关问题
Groovy - how to exit each loop?

I m new to Grails/Groovy and am trying to find a node in a an xml file; I ve figured out how to iterate over all of them, but I want to exit the loop when the target node is found. I ve read that ...

Eclipse Spring Builder set properties with Groovy beans

I typically use groovy to construct simple bean but the Spring IDE plugin to eclipse fails to build when I try to set a property that is generated by groovy without an explicit setter. For example, ...

How can I get this snippet to work?

I d like to port a little piece of code from Ruby to Groovy, and I m stuck at this: def given(array,closure) { closure.delegate = array closure() } given([1,2,3,4]) { findAll { it > 4} ...

Changing the value in a map in Groovy

This is about a very basic program I m writing in Groovy. I have defined a map inside a method: def addItem() { print("Enter the item name: ") def itemName = reader.readLine() print(...

Is functional Clojure or imperative Groovy more readable?

OK, no cheating now. No, really, take a minute or two and try this out. What does "positions" do? Edit: simplified according to cgrand s suggestion. (defn redux [[current next] flag] [(if flag ...

热门标签