Spring Data Неверное имя столбца - PullRequest
0 голосов
/ 05 апреля 2020

Я использую Spring boot 2 и Hibernate 5

Мой вывод из консоли

2020-04-05 19:17:20.087  WARN 3908 --- [nio-8290-exec-1] o.a.c.util.SessionIdGeneratorBase        : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [328] milliseconds.
Hibernate: 
    insert 
    into
        adv.t_address
        (created, created_at, state, updated, updated_at, additionalNumber, apartmentNumber, city, country, number, streetName) 
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2020-04-05 19:17:29.347  WARN 3908 --- [nio-8290-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 42703
2020-04-05 19:17:29.347 ERROR 3908 --- [nio-8290-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: column "additionalnumber" of relation "t_address" does not exist
  Position: 77
2020-04-05 19:17:29.378 ERROR 3908 --- [nio-8290-exec-1] 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 execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause
org.postgresql.util.PSQLException: ERROR: column "additionalnumber" of relation "t_address" does not exist

Мой столбец в модели сущностей

@Column(length = 50, nullable = false)
private String additionalNumber;

, а также я используя эти свойства

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

И мой вопрос: почему я не получаю столбец "дополнительный номер" вместо "дополнительный номер"?

Это журнал из БД. Кажется, БД получить застрял при возвращении

2020-04-05 18:41:39.856 UTC [622] STATEMENT:  insert into adv.t_address (created, created_at, state, updated, updated_at, additionalNumber, apartmentNumber, city, country, number, streetName) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
rentni_db  |    RETURNING *

1 Ответ

0 голосов
/ 05 апреля 2020

PostgreSQL следует правилам SQL. Это означает, что все имена таблиц и столбцов будут строчными, если они не заключены в кавычки.

@Column(name = "ADDITIONALNUMBER", length = 50, nullable = false) private String additionalNumber;

Может быть, это может помочь

...