Schema-validation: missing table for an auto-sequence id

While migrating hibernate-core from 5.6.10 to 6.1.7 and hibernate-validator to 8.0.0-Final I am getting missing table errors (on my entities auto increment ids) even though the table exists.

For some of my entities I can resolve this by using @GeneratedValue(strategy=GenerationType.IDENTITY) on the Id.

However, for some entities that inherit from a superclass and can’t be modified I’m stuck with this error.

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [`user_rev_entity_seq`]
		at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:133)
		at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:46)
		at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:96)
		at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation(AbstractSchemaValidator.java:74)
		at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:293)
		at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.lambda$process$5(SchemaManagementToolCoordinator.java:143)
		at java.base/java.util.HashMap.forEach(HashMap.java:1421)
		at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:140)
		at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:336)
		at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415)
		at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1423)
		at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:75)
		at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376)
		at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
	

Example below:

My class below UserRevEntity implements the interface DefaultRevisionEntity which has the @GeneratedValue id that I can’t modify to add the strategy.

@Entity
@RevisionEntity(UserRevisionListener.class)
public class UserRevEntity extends DefaultRevisionEntity {
    private Integer userId;
@MappedSuperclass
public class DefaultRevisionEntity implements Serializable {
    private static final long serialVersionUID = 8530213963961662300L;
    @Id
    @GeneratedValue
    @RevisionNumber
    private int id;

How should I fix this?

In Hibernate 6 the way we determine implicit names for @GeneratedValue sequences and tables has changed, see this chapter of the migration guide for more details. TLDR: Hibernate by default creates a sequence per entity hierarchy instead of a single sequence hibernate_sequence - that’s probably why you’re seeing this error now.

We suggest assuring you have all the correct sequences setup correctly, but as a workaround you can always go back to the previous behavior by specifying the naming strategy org.hibernate.id.enhanced.ImplicitDatabaseObjectNamingStrategy using the hibernate.id.db_structure_naming_strategy configuration property.