Open make opened 7 years ago
Maybe I'm missing something but why are you doing this? When you say to enable direct SQL inserts you mean to be able to do an insert without setting a value for the id
column?
Yes. I want to enable both manual SQL inserts and GORM inserts using the same auto-incrementing id sequence.
So mapping id defaultValue:"nextval('seq_foo')"
should be declared to enable following to work
new Sql(dataSource).executeInsert('INSERT INTO foo DEFAULT VALUES')
Equal GORM insert is
new Foo().save(flush:true)
I am using following domain class mapping to enable direct SQL inserts.
When using dbCreate = 'update' in datasource table and sequence are automatically created when running 'grails run-app'. The problem is that table is created first and causes error:
The workaround is to rerun "grails run-app".
Sequence should be created before table to fix that issue.