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?

7
задан mkoryak 7 December 2010 в 19:01
поделиться