The sequence "HIBERNATE_SEQUENCE" was not found; SQL statement

In my spring mvc application, I have the following object. I am trying to visualize data using devtoolin my application.

@Entity
@Data
public class ConsultationRequest {
    @Id
    @GeneratedValue
    private Long id;

    private String name;

    private String email;

    private String purpose;

    private String programme;

    private int year;

    private String language;

    private String comments;
    @Enumerated(EnumType.STRING)
    private ConsultationStatus status;
}

Then I used jpa to create the object:

@Repository
public interface ConsultationRequestRepository extends JpaRepository<ConsultationRequest, Long> {

}

The problem is that when I load the application, I encounter two errors:

 Unsuccessful: drop sequence hibernate_sequence
[36morg.hibernate.tool.hbm2ddl.SchemaExport  Sequence "HIBERNATE_SEQUENCE" not found; SQL statement:

Then when I open

http://localhost:8080/h2-console/

I do not see the table. It seems that the table is not created during the loading process.

+4
source share
2 answers

Update your code as below:

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

, hibernate hibernate_sequence .

Oracle/Postgres .
MySql , .

+10

persistence.xml

property name="hibernate.hbm2ddl.auto" value="create"

hdm2ddl

.

+1

Source: https://habr.com/ru/post/1656457/


All Articles