sbglasius opened a new issue, #16561:
URL: https://github.com/apache/grails-core/issues/16561

   ### Expected Behavior
   
   With `grails-data-hibernate7` 8.0.0, PostgreSQL and `dbCreate: create-drop`, 
domain classes with the default id
   mapping get their sequences created and can be saved, as with Hibernate 5.
   
   ### Actual Behaviour
   
   No `create sequence` statement is executed, and every save fails with:
   
   ```
   org.hibernate.HibernateException: Identifier generator 
(SequenceStyleGenerator) was not properly initialized.
   This usually happens if table creation failed (check previous logs for DDL 
errors).
   ```
   
   There are no DDL errors. The tables are created; only the sequences are 
missing.
   
   `GrailsNativeGenerator`'s constructor calls `initialize(null, null, 
context)` and ignores any exception it throws.
   On PostgreSQL the `NativeGenerator` delegate is a `SequenceStyleGenerator` 
that is never configured, so its sequence is
   never registered as an exportable. On H2 the native generator uses IDENTITY, 
which is probably why the tests don't
   catch it.
   
   Mapping ids with `id generator: 'sequence'` works, because 
`GrailsSequenceStyleGenerator` configures the generator
   and registers its exportables itself.
   
   ### Steps To Reproduce
   
   1. A Grails 8.0.0 app with `grails-data-hibernate7`, a PostgreSQL datasource 
and `dbCreate: create-drop`
   2. Any domain class with the default id mapping
   3. `new Book(title: 'x').save(flush: true)`
   
   ### Environment Information
   
   - Grails / GORM 8.0.0, `grails-data-hibernate7`, Hibernate 7.4.10.Final
   - PostgreSQL 17, Java 21
   
   ### Example Application
   
   https://github.com/gpc/grails-postgresql-extensions/pull/136 
(`test-apps/app2` works around it in `application.groovy`)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to