2

I have a Grails (v. 3.3.8) app with some scaffolded views which are based on tables in my Oracle 12c database. It all works well with a naive incremental ID generator but in order for it to work 100% according to the specification, I need to have it take the ID's from the database's sequences. For every table named A_B_C, I have a corresponding sequence named A_B_C_SEQ.

So normally, with SQL, I would get the next ID with a query like this: select A_B_C_SEQ.nextVal as seq from dual;. How do I go about translating it to Grails/GORM, so that it uses the sequence as well?

Straightfw
  • 2,143
  • 5
  • 26
  • 39
  • 1
    I am not 100% sure with Oracle, but with PostgreSQL you add the sequence to the domain class mapping like this ``` static mapping = { id generator:'sequence', params:[sequence: 'log_event_id_seq'] } ``` – Olav Grønås Gjerde Jan 30 '19 at 10:01
  • @OlavGrønåsGjerde - ha, that really is all it takes! Thanks a lot, if you want to upgrade your comment to an answer, I'd happily accept it :) – Straightfw Jan 30 '19 at 12:52

0 Answers0