org.postgresql.util.PSQLException:错误:关系" dish"不存在

时间:2016-12-11 12:27:45

标签: spring postgresql hibernate heroku heroku-postgres

我在heroku上创建了java(spring)app,将postgresql连接到它。当我在应用程序上发出请求时,日志显示

  

WARN 4 --- [io-14883-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper:SQL错误:0,SQLState:42P01   app [web.1]:2016-12-11 12:13:09.942 ERROR 4 --- [io-14883-exec-3] ohengine.jdbc.spi.SqlExceptionHelper:ERROR:relation" dish&#34 ;不存在   app [web.1]:职位:13   app [web.1]:2016-12-11 12:13:10.031 ERROR 4 --- [io-14883-exec-3] oaccC [。[。[/]。[dispatcherServlet]:Servlet.service()for路径[]中的servlet [dispatcherServlet]抛出异常[请求处理失败;嵌套异常是org.springframework.dao.InvalidDataAccessResourceUsageException:无法执行语句; SQL [不适用];嵌套异常是org.hibernate.exception.SQLGrammarException:无法执行语句的根本原因   app [web.1]:org.postgresql.util.PSQLException: ERROR:relation" dish"不存在   app [web.1]:职位:13

application.properties:

spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.maxActive=10
spring.datasource.maxIdle=5
spring.datasource.minIdle=2
spring.datasource.initialSize=5
spring.datasource.removeAbandoned=true
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=false
#spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true

此模型适用于我的本地计算机

型号:

@Entity
public class Dish
  implements Serializable
{
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Long dishId;
  private Long categoryId;
  private String name;
  private String description;
  private Float price;
  private String picUrl;

  public Long getId()
  {
    return this.dishId;
  }

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

  public Long getCategoryId()
  {
    return this.categoryId;
  }

  public void setCategoryId(Long categoryId)
  {
    this.categoryId = categoryId;
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String name)
  {
    this.name = name;
  }

  public String getDescription()
  {
    return this.description;
  }

  public void setDescription(String description)
  {
    this.description = description;
  }

  public Float getPrice()
  {
    return this.price;
  }

  public void setPrice(Float price)
  {
    this.price = price;
  }

  public String getPicUrl()
  {
    return this.picUrl;
  }

  public void setPicUrl(String picUrl)
  {
    this.picUrl = picUrl;
  }
}

1 个答案:

答案 0 :(得分:2)

#spring.jpa.hibernate.ddl-auto=create

被注释掉了。所以Hibernate不会创建你的表。这就是他们不存在的原因。