当使用table-per-hierarchy继承时,GORM 创建一个 'class' 列来存储实例的类名。
我想向该列添加数据库索引,因为我的许多 SQL 查询都包括where class='com.myapp.Mychildclass'
. 但是,我没有成功使用此代码:
static mapping = {
columns {
'class' column: 'class', index: 'class_idx'
}
}
我在没有创建索引的情况下尝试了此代码的不同版本。
我怎样才能做到这一点?