簡體   English   中英

錯誤:org.postgresql.util.PSQLException:錯誤:列 userinfo0_.dtype 不存在

[英]ERROR:org.postgresql.util.PSQLException:ERROR: column userinfo0_.dtype does not exist

我正在 Spring boot 中開發一個 Web 應用程序,並使用 PostgreSQL 作為我的數據庫。

我有四節課。 一個是父母,另外三個是孩子。 這是一種分層繼承。 我有父類中 3 個子類通用的字段,當我實現它時出現 dtype 錯誤,即它說我沒有在父類中鍵入 dtype 列,然后我添加了名為的 dtype 列作為數據庫中的 userInfo_type 並手動為其分配值“0”,並且在父類的實體類中我指定了這個

@DiscriminatorColumn(name="userInfo_type",discriminatorType = DiscriminatorType.INTEGER,columnDefinition = "0")
)

@DiscriminatorValue("1"),@DiscriminatorValue("2"),@DiscriminatorValue("3")

分別在三個子類中

注意:我沒有在四個實體中的任何一個實體中添加 userInfo_type 列作為屬性之一,也沒有在創建數據庫表和列的 db 腳本中添加,我在 db 中顯式添加了列並將@DiscriminatorColumn添加到父級和@DiscriminatoryValue分別給孩子們,在我運行后,我收到了這個錯誤

Caused by: org.postgresql.util.PSQLException: ERROR: column userinfo0_.user_info_type does not exist
  Hint: Perhaps you meant to reference the column "userinfo0_.userInfo_type".
  Position: 901
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2510)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2245)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:311)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:447)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:368)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159)
    at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:109)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
    ... 105 more
2020-03-23 13:16:21.572 DEBUG 8796 --- [nio-8080-exec-1] m.m.a.RequestResponseBodyMethodProcessor : Using 'application/json', given [*/*] and supported [

創建的(手動)列已命名為: userInfo_type而在將鑒別器字段名稱轉換為列名稱Hibernate 時,使用蛇形大小寫命名,在任何大寫字母之前加上下划線( _ )。

簡單地說: userInfo_type被解析為USER_INFO_TYPE而不是USERINFO_TYPE

如果您可以在表上手動操作,您可以將創建的列重命名為USER_INFO_TYPE

否則,您必須通過重新定義應用程序配置中的相應屬性來配置Spring命名策略。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM