【问题标题】:ERROR: "com.microsoft.sqlserver.jdbc.SQLServerException: Invalid column name 'order_id'"错误:\“com.microsoft.sqlserver.jdbc.SQLServerException:列名无效\'order_id\'\”
【发布时间】:2022-11-03 15:49:53
【问题描述】:
List<ACOrders> acOrders = ordersRepo.findAllByOrderId(44L);
@Repository
public interface ACOrdersRepository extends JpaRepository<ACOrders, Long> {

    ACOrders findByOrderId(Long orderId);

}

我使用 mssql 作为数据库,我的属性文件如下:

#mssql
spring.datasource.url=jdbc:sqlserver://<ip>:1433;database=<database>
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.properties.hibernate.format_sql=true

【问题讨论】:

    标签: java sql-server jpa


    【解决方案1】:

    我通过在 application.property 文件中添加两个附加属性解决了这个问题

    spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

    【讨论】:

      猜你喜欢
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多