Uploaded image for project: 'Hibernate ORM'
  1. HHH-10974

Schema-validation fails with MySQL and quoted uppercase table name

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.2.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 10
      MySQL 5.5.27 on a Win7 VM
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Hello,
      we have some projects created with Hibernate 4. At moving them to Hibernate 5.2.1 we run into a problem with Mysql databases:

      When the @Table name of an Entity is set to a quoted String like in the following example,
      the table can be created with hibernate.
      But when"javax.persistence.schema-generation.database.action" or "hibernate.hbm2ddl.auto" is set to "validate", it doesn't know the table any more.

      Entity:

      @Entity
      @Table(name = "`Language`")
      public class Language {
      	
      	private int id;
      	private String description;
      
      	@Id
      	@GeneratedValue(strategy = GenerationType.AUTO)
      	public int getId() {
      		return id;
      	}
      	...
      }
      

      In the example project, the database table for this entity is created at first application start with hibernate's schema generation without problems:

      <property name="javax.persistence.schema-generation.database.action" value="create-drop" />
      

      After switching this property to

      <property name="javax.persistence.schema-generation.database.action" value="validate" />
      

      now building the EntityManagerFactory/Sessionfactory fails, because schema validation doesn't find this table any more.

      Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: hibernate5example] Unable to build Hibernate SessionFactory
      	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:961)
      	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:891)
      	at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
      	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
      	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
      	at com.company.example.App.main(App.java:18)
      Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [`Language`]
      	at org.hibernate.tool.schema.internal.SchemaValidatorImpl.validateTable(SchemaValidatorImpl.java:130)
      	at org.hibernate.tool.schema.internal.SchemaValidatorImpl.performValidation(SchemaValidatorImpl.java:100)
      	at org.hibernate.tool.schema.internal.SchemaValidatorImpl.doValidation(SchemaValidatorImpl.java:67)
      ...
      

      With Hibernate 4.3, validation works for such entities.

      The MySQL databases' "lower_case_table_names" value is "1"

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              JoMei JohannesM
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: