JPA (hibernate provider) and Postgres 11
I have this configuration for my Id
property (it's a single column/attribute PK).
For some reason after doing an INSERT into this table, JPA calls
select currval('yb.asset_store_id_seq')
I guess (I am not sure) it's doing it to refresh the Id of the newly inserted entity or maybe for some similar reason.
But there's no such sequence. My sequence is named yb.asset_store_seq
and my table is yb.asset_store
.
My entity class is AssetStore
.
So... how do I get rid of this issue? Basically JPA is somehow making up this sequence name out of nowhere. Or am I missing something ?!
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false, insertable=false, updatable=false)
private Integer id;
On the DB level, the sequence is owned by the table.
Here is the stack trace.
Hibernate:
select
currval('yb.asset_store_id_seq')
Mar 25, 2020 3:45:02 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 42P01
Mar 25, 2020 3:45:02 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ERROR: relation "yb.asset_store_id_seq" does not exist
Position: 16
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
...................
Caused by: org.postgresql.util.PSQLException: ERROR: relation "yb.asset_store_id_seq" does not exist
Position: 16
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)