获取一系列SQL警告:"关系不存在,跳过"

时间:2018-04-02 20:02:51

标签: spring postgresql hibernate spring-boot

我不知道是否需要担心,但是当服务器启动时,我会收到一系列警告:

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
 ...

我可以&# 39;不要说这引起了一个问题 - 到目前为止一切正常 - 但我想了解这里发生了什么。

这是我正在使用的配置:

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

例如,@Entity 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; } }

data(){
   return{
    filterName:'Warszawa'
  }
},
computed:{
   filteredName(){
    return this.titles
    .filter((title)=>{
     return item.title.match(this.filterName);
})

1 个答案:

答案 0 :(得分:2)

当数据库尝试删除较旧的对象时,发生错误。 您可以使用spring.jpa.show-sql=true检查确切的时刻,但是,如果更改spring.jpa.hibernate.ddl-auto=create而不是create-drop,则不会再看到这些警告,因为它不会尝试删除不存在的对象。

来自Hibernate documentation

  

create将生成数据库删除,然后是数据库   创造。

     

create-drop删除架构,并在SessionFactory启动时重新创建。   此外,在SessionFactory关闭时删除架构。