0

I am new to spring boot and i am using Spring Boot, JPA and Hibernate to develop a sample Spring boot application. I am getting the following error.

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing sequence [tutorial_seq]

This is my Entity bean.

@Id @Column(name = "ID", insertable = false, updatable = false) @SequenceGenerator(name = "tutorial_seq_gen", sequenceName = "TUTORIAL_SEQ", allocationSize = 1) @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "tutorial_seq_gen")
private BigInteger id;

I have the sequence in Oracle db and a trigger that automatically generates the id by calling the sequence.

This is the Sequence from db.

SCOTT@orclpdb> select sequence_name from user_sequences where sequence_name='TUTORIAL_SEQ';

SEQUENCE_NAME

TUTORIAL_SEQ

SCOTT@orclpdb>

Is there a way to Omit/Skip the sequence generator in Hibernate? or is there a fix for this error?

Thanks in advance for your response.

1 Answer 1

0

If you want Hibernate to manage the schema, use:

spring.jpa.hibernate.ddl-auto=create

If you want to create a schema in Postgres use:

CREATE SEQUENCE tutorial_seq START WITH 1 INCREMENT BY 1;

You can also start with the last value.

CREATE SEQUENCE tutorial_seq START WITH <LAST_VALUE_IN_ENTITY_TABLE> INCREMENT BY 1;

Or, if the sequence already exists and you want to update it:

ALTER SEQUENCE tutorial_seq RESTART WITH <NEW_VALUE>;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Saurabh for your response. Sequence is already created in the db and i have used spring.jpa.hibernate.ddl-auto=UPDATE in my application.properties file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.