Я пытаюсь обновить базу данных, используя spring.jpa.hibernate.ddl-auto = update
от JPA. Но это не удается, потому что имя схемы содержит дефис.
Я использую следующие конфигурации JPA:
spring.jpa.database=MYSQL
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Все отлично работает, используя имя без дефиса. Но с дефисом я получаю следующую ошибку:
2019-03-06 17:48:14.767 INFO 17296 --- [gine[Catalina]]] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2019-03-06 17:48:14.770 INFO 17296 --- [gine[Catalina]]] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-03-06 17:48:14.852 INFO 17296 --- [gine[Catalina]]] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-03-06 17:48:15.163 INFO 17296 --- [gine[Catalina]]] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Starting...
2019-03-06 17:48:15.578 INFO 17296 --- [gine[Catalina]]] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Start completed.
2019-03-06 17:48:15.604 INFO 17296 --- [gine[Catalina]]] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Hibernate: alter table table-xxx.tablex add column column col_name_x varchar(255)
2019-03-06 17:48:16.857 WARN 17296 --- [gine[Catalina]]] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:580) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.migrateTable(AbstractSchemaMigrator.java:297) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-xxx.tablex add column col_name_x varchar(255)' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_92]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_92]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_92]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_92]