I have a table with primary key column getting values from an oracle sequence. If I insert a record into my table, the best way would be -
INSERT INTO TABLE VALUES(SCHEMA.SEQUENCE.NEXTVAL, value1, value2, value3)
However, when I use save method from JPARepository, a select query for fetching only SCHEMA.SEQUENCE.NEXTVAL is run at time of object creation and then an additional INSERT query is run at end of transaction.
SELECT SCHEMA.SEQUENCE.NEXTVAL FROM DUAL
INSERT INTO TABLE VALUES(val_from_select_query, value1, value2, value3)
This is resulting in almost double time. Is there a way to configure my entity in such a way that it fetches sequence value in the insert query resulting in overall just 1 round trip to the DB?