static constraints 约束

1.为了在查询中获得最佳性能,通常需要定制表索引定义 这就需要用到‘index’约束

class Person {
    String firstName
    String address
    static mapping = {
        table 'people'
        version false
        id column: 'person_id'
        firstName column: 'First_Name', index: 'Name_Idx'
        address column: 'Address', index: 'Name_Idx,Address_Index'
    }
}
请注意,在 index属性的值中不能有任何空格,在这个例子中
index:'Name_Idx, Address_Index'会导致错误

猜你喜欢

转载自blog.csdn.net/csy_system/article/details/80492706