1

I'm trying to run a SpringBoot application but it is failing due to a Hibernate validation:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [SCHEMA.TABLE]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateTable(AbstractSchemaValidator.java:121)
at org.hibernate.tool.schema.internal.GroupedSchemaValidatorImpl.validateTables(GroupedSchemaValidatorImpl.java:42)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation(AbstractSchemaValidator.java:89)

I do know this is happening due to the Hibernate validation (it works when I disable it), however, the error doesn't make sense to me as the table does exist on my database (Mysql 5.7)

Any help would be appreciated.

Update 1:

I'm mapping my entity with annotations:

@Entity
@Table(name = "TABLE", catalog = "SCHEMA", schema = "")

while my persistence configuration file is quite simple:

@Configuration
@EnableTransactionManagement
public class PersistenceConfig {

    @Autowired
    private DataSource dataSource;

    @Bean
    public LocalContainerEntityManagerFactoryBean getEntityManager() {
        LocalContainerEntityManagerFactoryBean em
                = new LocalContainerEntityManagerFactoryBean();
        em.setDataSource(dataSource);
        em.setPackagesToScan(new String[] { "my.package" });

        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        em.setJpaVendorAdapter(vendorAdapter);
        em.setJpaProperties(additionalProperties());

        return em;
    }

    Properties additionalProperties() {
        Properties properties = new Properties();
        properties.setProperty("hibernate.hbm2ddl.auto", "validate");
        properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");

        return properties;
    }
pedrohreis
  • 1,030
  • 2
  • 14
  • 33
  • 1
    I believe it is actually looking for a table named 'TABLE' in a schema named ' SCHEMA' as it is saying: missing table [SCHEMA.TABLE] Can you add your configuration? – niekname Jun 10 '19 at 09:44
  • yes show us your configuration files. – Rmahajan Jun 10 '19 at 09:45
  • @niekname, I realized that, however, the table does exist in the database! – pedrohreis Jun 10 '19 at 09:51
  • 1
    Possible duplicate of [Schema-validation: missing table \[game\]](https://stackoverflow.com/questions/44479406/schema-validation-missing-table-game) – Rmahajan Jun 10 '19 at 09:59
  • 1
    For MySQL, you might want to ignore Schema/Catalog settings. This is because the "database" part of the JDBC URL (the one after the last slash) points to the database name, which is semantically identical to schema (for MySQL). – Abhijeet Jun 10 '19 at 11:25

0 Answers0