Could not fetch the SequenceInformation from the database ERROR but still everything works
Asked Answered
B

1

8

I've created user and userRole tables

user entity

@Entity
@Table(name = "USERS")
public class User {
    @Id
    @Column(name = "USERNAME",  nullable = false,  unique = true)
    private String username;

    @Column(name = "PASSWORD", nullable = false)
    private String password;

    @Column(name = "ENABLED", nullable = false)
    private boolean enabled = true;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user", fetch = FetchType.EAGER)
    private Set<UserRole> userRole = new HashSet<>();

userRole entity

@Entity
@Table(name = "USER_ROLES", uniqueConstraints = @UniqueConstraint(
        columnNames = { "ROLE", "USERNAME" }))
public class UserRole {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "user_role_id",
            unique = true, nullable = false)
    private Integer userRoleId;

    @Column(name = "ROLE")
    private String role;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "USERNAME")
    private User user;

When i launch my app i get an Error and this stack trace:

ERROR JdbcEnvironmentImpl:420 - Could not fetch the SequenceInformation from the database
org.h2.jdbc.JdbcSQLException: Column "start_with" not found [42122-197]

But i don't have any 'start_with' columns. Before my UserRole entity was without userRoleId column and everything worked fine but then i added it to do 'role' column not unique and then this happened. But still everything works fine, i just disturbed by this error, what can be the couse of it?

Bria answered 26/3, 2019 at 8:1 Comment(0)
F
8

I suggest checking your Hibernate dialect.

I had a similar error because of a start_value column that Hibernate was looking for in sequences of my PostgresQL database. This field name is a default value in Hibernate's SequenceInformationExtractorLegacyImpl class which has many subclasses, each depending on your precise database server and its version. Hibernate loads the right class according to the dialect you specify.

In my case, I was using the org.hibernate.dialect.PostgreSQLDialect dialect, a (deprecated) class meant to be used with a PostgesQL 8.2 version. I switched to org.hibernate.dialect.PostgreSQL9Dialect since my database was hosted on a PostgresQL 9 server. And the issue was gone.

Fixture answered 3/9, 2019 at 15:22 Comment(5)
I'm using org.hibernate.dialect.HSQLDialect.Bria
Indeed, you have only one possible dialect for Hsql database. I was wrong in any case : I thought my error had disappeared but it was still there. The real cause of my issue is this bug hibernate.atlassian.net/browse/HHH-13291Fixture
After almost a year i googled the same question and found my question here. Red it again and i understood that this man was right. I was using wrong dialect all this time.Bria
I am also facing the same issue, can you please tell me even with this error, why application works, and there is no issueGratuity
probably because try catch hidden inside dialect. It can't find column but ignores this error and goes on.Bria

© 2022 - 2024 — McMap. All rights reserved.