简体   繁体   English

JPA '.'(点)在列名中

[英]JPA '.'(dot) in column name

I have a Spring Boot app (REST API) that uses JPA Entities with a SQL Server 2012 view.我有一个 Spring 启动应用程序(REST API),它使用 JPA 实体和 SQL Server 2012 视图。 In that view I have a column在那个视图中,我有一个专栏

S.N.

When Running the Spring Boot App and accessing the said entity(through API), I get the following error.运行 Spring 引导应用程序并访问所述实体(通过 API)时,我收到以下错误。

o.h.engine.jdbc.spi.SqlExceptionHelper   : Invalid column name '`s_n` '.

I have tried escaping the annotation with backticks as well as putting column name in quotes我试过 escaping 带有反引号的注释以及将列名放在引号中

@Column(name="[`S.N` ]")
@Column(name="\"S.N.\"")

Do note that changing the column name is not possible at the moment as I have no control over the database.请注意,目前无法更改列名,因为我无法控制数据库。

Fixed this by add the following to application.properties通过将以下内容添加到application.properties来解决此问题

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

Referenced from this answer从这个答案引用

https://stackoverflow.com/a/48442812/8277643 https://stackoverflow.com/a/48442812/8277643

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM