我有我的模型: type Report struct {
ID int `json:"id,omitempty" gorm:"primary_key"`
Title *string `json:"title" gorm:"not null"`
}
我已经初始化的变量report为我已经成功地自动迁移该模型的数据库表和使用GORM的db.Create(&report)已填
这是我 class Student {
static hasMany = class: Class
static belongsTo = Class
}
class Class {
static hasMany = student: Student
}
我想,以防止任何级联删除。如果一个类被删除,那么即使它们“属于”Class对象,该学生也不应该成为它。
想象我有2层结构: type Order struct {
ID int64 `gorm:"primary_key"`
CurrentStateID int64
CurrentState *OrderState
}
type OrderState struct {
ID int64
.... // other fields
}
现
我正在使用Grails 3.2.8。我想在生成一个id时允许这两个选项。如果未分配,是否有使用分配和回退顺序的方法?我尝试在构造函数中获取下一个id并在其中设置id,但遇到问题。任何帮助/指导将不胜感激。 class Foo {
static mapping = {
id generator:'assigned'
}
}
VS class Foo {