Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting series of SQL warnings: "relation <table> does not exist, skipping"

I don't know if it's something to worry about but as the server starts up I am getting a series of these warnings:

o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "app_user__user_group" does not exist, skipping
o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "app_user__user_group" does not exist, skipping
o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
o.h.engine.jdbc.spi.SqlExceptionHelper   : relation "google_place" does not exist, skipping
o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 0, SQLState: 00000
 ...

I can't say that this is causing an issue - so far everything works - but I'd like to understand what's going on here.

This is the configuration I am using:

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
# Because detection is disabled you have to set correct dialect by hand.
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
spring.datasource.url=jdbc:postgresql://localhost/test-db
spring.datasource.username=postgres
spring.datasource.password=root
spring.datasource.driver-class-name=org.postgresql.Driver
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
#spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=create-drop
  # update
  # create-drop

Here, as an example, is the @Entity for google_place:

@Entity
@Table(name = "google_place")
public class GooglePlace extends AbstractTimestampEntity {

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

    @OneToOne
    @JoinColumn(name = "place_id")
    private Place place;

    @Column(name = "google_place_id", unique = true)
    private String googlePlaceId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Place getPlace() {
        return place;
    }

    public void setPlace(Place place) {
        this.place = place;
    }

    public String getGooglePlaceId() {
        return googlePlaceId;
    }

    public void setGooglePlaceId(String googlePlaceId) {
        this.googlePlaceId = googlePlaceId;
    }

}
like image 728
Stefan Falk Avatar asked Apr 02 '18 20:04

Stefan Falk


1 Answers

The error occurs when the database tries to drop the older objects. You can check the exact moment when it happens with spring.jpa.show-sql=true, however, if you change spring.jpa.hibernate.ddl-auto=create instead of create-drop you will not see those warnings anymore because it will no attempt to drop nonexistent objects.

From Hibernate documentation:

create Database dropping will be generated followed by database creation.

create-drop Drop the schema and recreate it on SessionFactory startup. Additionally, drop the schema on SessionFactory shutdown.

like image 70
Ezequiel Victorero Avatar answered Oct 17 '22 09:10

Ezequiel Victorero