开发者

Grails Domain Classes id

开发者 https://www.devze.com 2023-03-02 23:06 出处:网络
When creating objects in my domain class, id is automatically created - and in my sql database, it is created a column called id as well.

When creating objects in my domain class, id is automatically created - and in my sql database, it is created a column called id as well.

I want that column to be named, for example, "book_id" in class book and "movie_id" in class movie. My quest开发者_开发问答ion is, how can i change the name?


You can explicitly declare the name of the identifier column using mapping like this:

class Book {
  ..
  static mapping = {
    id column:'book_id'
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消