Ran into a peculiar problem. I am using JPA + spring to handle my entities. Data are saved in Postgresql. Tables are generated by JPA. I didn't create any of them.
One of the entity 'Family' has an ID field.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="family_id",nullable = false, columnDefinition = "BIGINT")
private Long id;
So, JPA (or hibernate) generate a column with a sequence 'family_id_seq'. It will query currval('family_id_seq') when new entry are being inserted. Everything works as expected.
Today when I debugging my program. Suddenly I cannot save any 'Family' using JpaRepository. The error message is currval('family_family_id_seq') does not exist.
Why does my JPA changed the generated seq name? How do I control this? Which class of Spring JPA is responsible for creating this query? I want my seq named 'family_id_seq'. Because other tables' seq is still following that rule.