gpt4 book ai didi

oracle - Spring 启动/JPA : Quoted reserved word column name not working

转载 作者:行者123 更新时间:2023-12-02 01:14:58 27 4
gpt4 key购买 nike

我有一个 Oracle 表,其中有一列以保留字 (TYPE) 命名

这在实体类中定义为

@Entity
@Table(name="PROCESS_STORAGE")
.....
@Column(name="\"TYPE\"")
private String type;

但是尝试从数据库检索记录会导致错误:

2018-01-05 11:50:54.139  WARN 9340 --- [http-nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 904, SQLState: 42000
2018-01-05 11:50:54.139 ERROR 9340 --- [http-nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-00904: "PROCESSSTO0_"."type": invalid identifier
2018-01-05 11:50:54.144 ERROR 9340 --- [http-nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause

java.sql.SQLSyntaxErrorException: ORA-00904: "PROCESSSTO0_"."type": invalid identifier

不太确定我在这里缺少什么。它似乎引用了列名,但没有找到它?

编辑我刚刚意识到这是一个区分大小写的问题 - 该列在数据库(类型)和实体定义中是大写的,但由于某种原因它在查询中被转换为小写。但仍然不确定为什么会发生这种情况

最佳答案

我想我已经找到解决办法了 here

在application.properties中,需要指定

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

关于oracle - Spring 启动/JPA : Quoted reserved word column name not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48113145/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com