Grails Domain - get read save

//调用后,数据库会更新
    def show(Long id) {
        def c = Company. get(id)
        c.name = 'testtest'
        [company: c]
    }

    def show(Long id) {
        def c = Company. findById(id)
        c.name = 'test2'
        [company: c]
    }

    def show(Long id) {
        def c = Company. read(id)
        c.name = 'testtest'
        c. save()
        [company: c]
    }


//调用后,数据库不会更新
    def show(Long id) {
        def c = Company. read(id)
        c.name = 'testtest'
        [company: c]
    }

你可能感兴趣的:(grails)