3

I am trying to map an existing oracle table to a new Grails Domain Object. I also have an existing sequence. When calling "run-app", I get an error:

Unsuccessful: create sequence hibernate_sequence
ORA-01031: insufficient privileges

My goal is to use the existing sequence, and not create a new one. For the record, this is my first Grails/Groovy attempt.

My domain object looks like below. Table name is Uicc_Inv_Detail. PK is UICC_INV_DETAIL_ID. Other columns are the same name as in Uicc Class. Sequence name is Uicc_Inv_Detail_Seq.
I assume my whole "id generator" section is wrong.

class Uicc {
  String id
  String iccid
  String imsi

  static mapping = {
    version false
    table 'Uicc_Inv_Detail'
    id generator: 'sequence',column:'UICC_INV_DETAIL_ID',
            params:  [table: 'Uicc_Inv_Detail_Seq', column: 'nextval']

  }

    static constraints = {
    }
}
Mateng
  • 3,742
  • 5
  • 37
  • 64
Noa
  • 33
  • 1
  • 3

1 Answers1

6

Use:

id generator:'native', params:[sequence:'Uicc_Inv_Detail_Seq']

Here's the docs: http://grails.org/doc/2.0.x/ref/Database%20Mapping/id.html http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/mapping.html#mapping-declaration-id-generator

Raphael
  • 1,760
  • 1
  • 12
  • 21
  • This worked, thanks. I just had to modify it to `id column: 'uicc_inv_detail_id', generator:'native', params:[sequence:'Uicc_Inv_Detail_Seq']` – Noa Nov 09 '12 at 16:10