Reputation: 127
I have problem with right set configuration of spring-boot, jpa and postgresql database.
All my queries hibernate launch without quotes and in lowercase. Postgresql dont accept this, and return error.
My application.yml file:
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/
Example of enitity:
@Entity
@Table(name="RecommendationItem")
public class RecommendationItem {
And preview of hibernate query log:
Hibernate: select recommenda0_.id as id1_2_ [...] from recommendation_item recommenda0_ where recommenda0_.user_id=?
And error:
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
It is possible to config this architecture without renaming all annotation in entities?
Upvotes: 0
Views: 1579
Reputation: 246053
I can think of two possibilities:
The configuration parameter search_path
does not include the schema that contains recommendation_item
, so it cannot be found.
Solution: add the schema to search_path
.
You kept the table name in upper case when you migrated the table from Oracle, so it is called RECOMMENDATION_ITEM
.
The problem here is that while Oracle folds unquoted names to upper case, as the SQL standard directs, while PostgreSQL folds them to lower case.
There are two solutions:
"RECOMMENDATION_ITEM"
.Upvotes: 1