开发者

How to use a custom id column in GORM

I have a domain object that has a property that i want to be used as the id by GORM, the reason being is that ill be saving lists of this object and i want existing rows to be updated if the id already exists in the database

Lets assume that my property i want as the PK is called listId

Ive seen several approaches to this, which is best?

1:

id generator: 'identity', column: 'listId'

2:

  static mapping = {
    id generator开发者_开发知识库:'assigned'
  }
  def getKey = {
    return listId;
  }

or something entirely different?


  static mapping = {
    id generator: 'assigned', name: "listId", type: 'string'
  }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜