title: how to fix incompatible foreign key constraints spring boot
body: <p>I have a spring boot application where I have two entities in a relationship. MeetingsSetting and meetingTime. One MeetingSetting can have multiple meetingTimes and one meetingtime belongs to one Meetingsetting.</p>
  <p>I generate the databases through sql script and reference the foreing key their for the meetingTime entity. But I am getting the following error:</p>
  <pre><code>Caused by: java.sql.SQLException: Referencing column 'meeting_name' and referenced column 'id' in foreign key constraint 'FK1omm6fk51xdsd0kysqbmleweg' are incompatible.
  </code></pre>
  <p>THe funny thing is I am not referencing the id anywhere not in my entity nor in my script. This is how my entity and script looks like:</p>
  <p>meetingSetting:</p>
  <pre><code>@Entity
  @Table(name = &quot;meeting_settings&quot;)
  @Data
  
  public class MeetingsSetting {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Column(name = &quot;meeting_name&quot;)
      private String meetingName;
  
      @Column(name = &quot;meeting_url&quot;)
      private String meetingUrl;
  
      @Column(name = &quot;meeting_pw&quot;)
      private String meetingPw;
  
      @OneToMany(mappedBy = &quot;meeting_Name&quot;, cascade = CascadeType.ALL)
      private Set&lt;MeetingTime&gt; meetingTime = new HashSet&lt;&gt;();
  }
  </code></pre>
  <p>MeetingTime:</p>
  <pre><code>@Entity
  @Table(name = &quot;meeting_times&quot;)
  @Data
  public class MeetingTime {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Column(name = &quot;meeting_date&quot;)
      private String date;
  
      @Column(name = &quot;start_time&quot;)
      private String startTime;
  
      @Column(name = &quot;end_time&quot;)
      private String endTime;
  
      @Column(name = &quot;meeting_name&quot;,insertable = false, updatable = false )
      private String meetingName;
  
      @ManyToOne
      @JoinColumn(name = &quot;meeting_name&quot;, nullable = false)
      private MeetingsSetting meeting_Name;
  }
  </code></pre>
  <p>and this is my script where I generate my tables:</p>
  <pre><code>-- auto-generated definition
  create table meeting_settings
  (
      id           bigint auto_increment
          primary key,
      meeting_name varchar(255) null,
      meeting_pw   varchar(255) null,
      meeting_url  varchar(255) null
  );
  
  create table meeting_times
  (
      id                  bigint auto_increment
          primary key,
      meeting_date        varchar(255) null,
      start_time          varchar(255) null,
      end_time            varchar(255) null,
      meeting_name        varchar(255) null,
      constraint fk_meeting_times_meeting_name
          foreign key (meeting_name) references meeting_settings (meeting_name)
  );
  </code></pre>
  <p>What could cause such an error? because I am not referencing anywhere the id.</p>
  <p>UPDATE:</p>
  <pre><code>spring.datasource.url=jdbc:mysql://localhost:3306/coorporate_blinddate?createDatabaseIfNotExist=true&amp;useSSL=true&amp;serverTimezone=UTC
  spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
  spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=../generate.sql
  spring.jpa.show-sql= true
  spring.jpa.generate-ddl=true
  spring.jpa.hibernate.ddl-auto = update
  spring.datasource.driver-class-name= com.mysql.jdbc.Driver
  spring.datasource.username=root
  spring.datasource.password=Test1234@@1&amp;
  server.port=8081
  </code></pre>
  <p>Hibernate Sequence:</p>
  <pre><code>Hibernate: create table meeting_settings (id bigint not null auto_increment, meeting_name varchar(255), meeting_pw varchar(255), meeting_url varchar(255), primary key (id)) engine=InnoDB
  Hibernate: create table meeting_settings_meeting_time (meetings_setting_id bigint not null, meeting_name bigint not null, primary key (meetings_setting_id, meeting_name)) engine=InnoDB
  Hibernate: create table meeting_times (id bigint not null auto_increment, meeting_date varchar(255), end_time varchar(255), meeting_name varchar(255), start_time varchar(255), primary key (id)) engine=InnoDB
  Hibernate: alter table meeting_settings drop index UK_klg4vqmhi7o9qff83ymly598o
  Hibernate: alter table meeting_settings add constraint UK_klg4vqmhi7o9qff83ymly598o unique (meeting_name)
  Hibernate: alter table meeting_settings_meeting_time drop index UK_jsn83wsxfkpm1xfencvsdkqj1
  Hibernate: alter table meeting_settings_meeting_time add constraint UK_jsn83wsxfkpm1xfencvsdkqj1 unique (meeting_name)
  Hibernate: alter table meeting_settings_meeting_time add constraint FK9lq62drkkslq6x381b3lieruu foreign key (meeting_name) references meeting_times (id)
  Hibernate: alter table meeting_settings_meeting_time add constraint FKglhgb5vgsviqm7t6vtmdx5e7t foreign key (meetings_setting_id) references meeting_settings (id)
  Hibernate: alter table meeting_times add constraint FK1omm6fk51xdsd0kysqbmleweg foreign key (meeting_name) references meeting_settings (id)
  </code></pre>
  <p>A table which is generated</p>
  <pre><code>meeting_settings_meeting_time
  meetings_setting_id
  meeting_name
  PRIMARY
  UK_jsn83wsxfkpm1xfencvsdkqj1
  FK9lq62drkkslq6x381b3lieruu
  FKglhgb5vgsviqm7t6vtmdx5e7t
  UK_jsn83wsxfkpm1xfencvsdkqj1
  </code></pre>