Ultimately, I'm trying to manage the database via flyway and use Quarkus and ORM at runtime. I'm trying to define a Table and corresponding ID attribute properly so that I can use Identity or Sequence. I've tried various combinations of
@GeneratedValue(strategy = GenerationType.XXX)
with
id int IDENTITY(1,1),
or
[id] [bigint] PRIMARY KEY NOT NULL DEFAULT (NEXT VALUE FOR dbo.CustomerID),
and it keeps coming back to SQL Error: 208, SQLState: S0002 / Invalid object name 'hibernate_sequence' when I try to persist a new entity, until I set "hibernate.id.new_generator_mappings" to "false".
Moving configuration to persistence.xml seems to have a ton of downside. For example, I'll have to move quarkus.hibernate-orm.database.generation=drop-and-create to persistence.xml and I'll lose the ability to toggle by environment.
I'm hoping someone has an example how to properly define a table's ID and the corresponding annotations that might be needed in the Entity without having to set "hibernate.id.new_generator_mappings" to false.
Right now I have working....
CREATE SEQUENCE CustomerID
START WITH 1
INCREMENT BY 1
NO CACHE
;
CREATE TABLE [Customer](
[id] [bigint] PRIMARY KEY NOT NULL DEFAULT (NEXT VALUE FOR dbo.CustomerID),
[name] [varchar](255) NOT NULL);
extending PanacheEntity and using the default...
@Id
@GeneratedValue
public Long id;
and setting "hibernate.id.new_generator_mappings" to "false" in the persistence.xml. As mentioned above, this begins to limit flexibility.
Thanks for any help on this frustrating scenario.