title: Hibernate Error executing DDL via JDBC Statement with Postgres
body: <p>I'm having a little trouble with my entities (using Spring-boot). I just can't seem to understand what might be the problem. What might be the reason that hibernate does not find the relations between the entities?</p>
  <p>I am getting the following <strong>exceptions</strong> when trying to run the application:</p>
  <pre><code>Error executing DDL &quot;alter table order_barcode drop constraint FK16yppq17qkt9vaiw536c468xq&quot; via JDBC Statement
  Caused by: org.postgresql.util.PSQLException: ERROR: relation &quot;order_barcode&quot; does not exist
  Error executing DDL &quot;alter table &quot;orders&quot; drop constraint FK7nkj808174vaoen3hn8lp39i6&quot; via JDBC Statement
  ERROR: relation &quot;orders&quot; does not exist
  ERROR: relation &quot;order_ticket&quot; does not exist
  </code></pre>
  <p><strong>Entities</strong></p>
  <pre><code>@Entity
  @Table(name=&quot;\&quot;orders\&quot;&quot;)
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  public class Order {
  
      public enum OrderStatus {
       
          INITIALIZED(&quot;initialized&quot;),
          COMPLETE(&quot;complete&quot;),
          FAILED(&quot;failed&quot;);
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
    
      @NotNull
      @Enumerated(EnumType.STRING)
      private OrderStatus status;
  
      @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
      @JoinColumn(name = &quot;order_id&quot;)
      private Set&lt;OrderTicket&gt; tickets;
  
      @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      private OrderPayment payment;
  }
  </code></pre>
  <pre><code>@Entity
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  public class OrderBarcode {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY) 
      private Long id;
  
      private String barcode;
  }
  
  </code></pre>
  <pre><code>@Entity
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  public class OrderPayment {
  
      public enum PaymentStatus {
          INITIALIZED(&quot;initialized&quot;),
          AUTHORIZED(&quot;authorized&quot;),
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY) 
      private Long id;
  
      @NotNull
      @Enumerated(EnumType.STRING)
      private PaymentStatus status;
  }
  </code></pre>
  <pre><code>@Entity
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  public class OrderTicket {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY) 
      private Long id;
  
      private Long templateId;
     
      @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      @JoinColumn(name = &quot;ticket_id&quot;)
      private Set&lt;OrderBarcode&gt; barcodes;
  }
  
  </code></pre>
  <p><strong>Configuration</strong></p>
  <pre><code>spring:
    datasource:
      url: jdbc:postgresql://localhost:5432/test
      username: ${DATABASE_USERNAME}
      password: ${DATABASE_PASSWORD}
      driver-class-name: org.postgresql.Driver
    jpa:
      hibernate:
      database-platform: org.hibernate.dialect.PostgreSQL82Dialect
        ddl-auto: create-drop
        # ddl-auto: update
      properties:
        hibernate:
         connection:
            characterEncoding: utf-8
            CharSet: utf-8
            useUniCode: true
         show-sql: false
          hbm2ddl:
            import_files: sql/import.sql
            import_files_sql_extractor: org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor
  </code></pre>