Spring Boot - Hibernate import.sql列名转换为大写

时间:2017-12-11 15:05:19

标签: sql spring hibernate spring-boot

我想使用import.sql将默认条目导入我的数据库,并在ddl-auto: create-drop执行。

INSERT INTO CAR (vehicleId, manufacturer, model, bodyDesign, capacity, capacityUnit, constructionDate, cylinders, doors, fuelType, gears, gearBox, isElectric, ps, seats, propulsion) VALUES ("WBA5J71050GZ75477", "BMW", "M3", "Coupé", 3246, "m³", PARSEDATETIME('17-03-2015', 'dd-MM-yyyy'), 6, 2, "petrol", 6, "semi-automatic", false, 343, 5, "rear");

但是我要插入的列名称会自动转换为大写:

2017-12-11 15:57:04.668 ERROR 24141 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000388: Unsuccessful: INSERT INTO CAR (vehicleId, manufacturer, model, bodyDesign, capacity, capacityUnit, constructionDate, cylinders, doors, fuelType, gears, gearBox, isElectric, ps, seats, propulsion) VALUES ("WBA5J71050GZ75477", "BMW", "M3", "Coupé", 3246, "m³", PARSEDATETIME('17-03-2015', 'dd-MM-yyyy'), 6, 2, "petrol", 6, "semi-automatic", false, 343, 5, "rear")
2017-12-11 15:57:04.668 ERROR 24141 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : Column "VEHICLEID" not found; SQL statement:

如果不重命名我的所有列,有没有办法绕过这个问题?

1 个答案:

答案 0 :(得分:0)

通过在application.yml

中设置spring.jpa.hibernate.naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl来解决
server:
  contextPath:

spring:
  jackson:
    serialization:
      INDENT_OUTPUT: true   
  jpa:
    hibernate:
      ddl-auto: create-drop

spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl