hibernate - 不要更新或删除数据库中的数据

标签 hibernate grails gorm

我有杜曼课:

package testgrails12
class Teams {
String name
static mapping = {
version false
}
static constraints = {
name nullable: true
}
}

我正在尝试从 Controller 中的表中删除或更新数据:
def team = Teams.get(1)
team.delete()

更新:
team.name = '123'
team.save()

在第一种或第二种情况下,我都没有得到结果。我也没有任何错误。我糊涂了。就是行不通。我在数据库中看到了结果。

最佳答案

一个不错的起点是生成 View 和 Controller ,以了解 View 和 Controller 之间如何发生“填充”,然后运行generate-all命令。

generate-all testgrails12.Teams

最后,您将获得一个TeamsController和所有相关的gsps。

您还可以使用scaffolding,它与上面的基本相同,但是所有魔术都被隐藏了。
创建以下Teams Controller :
class TeamsController {
    static scaffold = Teams
}

关于hibernate - 不要更新或删除数据库中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43153369/

相关文章:

grails - 脚手架 Controller Action

grails - 是否可以在AWS Lambda上运行Groovy Grails应用程序

grails - 在不级联删除的情况下链接Grails中的域对象

grails - 不需要的GORM表创建

mysql - 我无法连接 MySQL 数据库 WildFly - Hibernate

mysql - Spring JPA hibernate MariaDB

java - 具有集合的 Hibernate 或 SQL 查询 M-N 成员?

java - 如何使用camelCase将Hibernate实体字段映射到snake_case(下划线)数据库标识符

java - 将 Grails 3 应用程序部署到 Elastic Beanstalk 上的 Tomcat 8

grails - Grails GORM默认排序字段,它也是组合键的字段