Я разрабатываю веб-приложение при загрузке Spring и использую 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 [