title: hibernate foreign key issue : Error executing DDL "alter table..."
body: <p>I have a pretty simple object structure that is giving me an error I'm not able to resolve. Have done a bunch of searching, and I think this must be a pretty common use case, so not sure what the issue is. I have these three classes:</p>
  
  <pre><code>@Entity
  public class Widget {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int idd;
      private Date date;
      private String type;
      private int ownerId;
  
      @OneToOne(cascade = CascadeType.ALL)
      private Rating rating;
  
  
      @OneToMany(cascade = CascadeType.ALL)
      private List&lt;Tag&gt; tagList;
  
  
  }
  
  
  @Entity
  public class Rating {
  public enum ChartType  {RADAR, BAR, LINE, STAR};
  
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private int ratingId;
  private String name;
  
  @Enumerated(EnumType.STRING)
  private ChartType chartType;
  private double normalizedValue;
  
  @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
  private List&lt;RatingComponent&gt; componentList = new ArrayList&lt;&gt;();
  
  
  public Rating() {
      buildNormalizedValue();
  }
  }
  
  
  @Entity
  public class RatingComponent {
  
  
  @Id
  @GeneratedValue()
  private int compId;
  
  private String name;
  private double value;
  private double maxValue;
  
  }
  </code></pre>
  
  <p>when saving in the DAO I'm getting errors I don't really understand, such as </p>
  
  <pre><code>2018-07-23 11:43:07,208 WARN o.h.t.s.i.ExceptionHandlerLoggedImpl [main] GenerationTarget encountered exception accepting command : 
  Error executing DDL "alter table Rating_RatingComponent drop foreign key FKaudjguwlo1i8tm2jgli5bbnq6" via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table Rating_RatingComponent drop foreign key FKaudjguwlo1i8tm2jgli5bbnq6" via JDBC Statement
  </code></pre>
  
  <p>and further down</p>
  
  <pre><code>2018-07-23 11:43:07,644 WARN o.h.t.s.i.ExceptionHandlerLoggedImpl [main] GenerationTarget encountered exception accepting command : Error executing DDL "create table RatingComponent (compId integer not null, maxValue double precision not null, name varchar(255), value double precision not null, primary key (compId)) engine=InnoDB" via JDBC Statement
  org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table RatingComponent (compId integer not null, maxValue double precision not null, name varchar(255), value double precision not null, primary key (compId)) engine=InnoDB" via JDBC Statement
  </code></pre>
  
  <p>I have these properties in my config</p>
  
  <pre><code>    &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt; 
  </code></pre>
  
  <p>I thought I had gone thru the docs pretty carefully, and think this is a pretty straight forward object design...any ideas as to how to resolve, and where in the docs should I research more carefully to understand the root cause?</p>
  
  <p>thanks!</p>