我在spring、jpa和postgresql数据库的正确设置配置上有问题.
我所有的查询,hibernate启动,没有引号和小写。Postgresql不接受这一点,并返回错误。
我的application.yml文件:
spring:
datasource:
url: jdbc:postgresql://127.0.0.1:5432/xxx
username: xxx
password: xxx
driver-class-name: org.postgresql.Driver
dialect: org.hibernate.dialect.PostgreSQL94Dialect
jpa:
show-sql: true
naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
hibernate:
ddl-auto: none
default-schema: madmax
dialect: org.hibernate.dialect.PostgreSQL94Dialect
database-platform: org.hibernate.dialect.PostgreSQL94Dialect
hadoop:
config:
fs.defaultFS: hdfs://192.168.56.104:54310/环境的例子:
@Entity
@Table(name="RecommendationItem")
public class RecommendationItem {以及hibernate查询日志的预览:
Hibernate: select recommenda0_.id as id1_2_ [...] from recommendation_item recommenda0_ where recommenda0_.user_id=?和错误:
SEVERE: 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
org.postgresql.util.PSQLException: ERROR: relation "recommendation_item" does not exist可以配置此体系结构,而无需重命名实体中的所有注释?
发布于 2017-05-09 13:59:37
我能想到两种可能性:
search_path不包括包含recommendation_item的架构,因此找不到它。
解决方案:将模式添加到search_path。RECOMMENDATION_ITEM。
这里的问题是,当Oracle将未引用的名称折叠为大写时,正如SQL标准所指示的那样,而PostgreSQL则将它们折叠为小写。
有两种解决方案:- Rename the tables to lower case names.我认为这是更好的解决方案。
-始终使用引用的参数,如"RECOMMENDATION_ITEM"。
https://stackoverflow.com/questions/43871743
复制相似问题