title: Hibernate unable to add foreign key constraint
body: <p>I have already created database and all tables with all foreign key constraints. But when I run the spring boot application hibernate is throwing error</p>
  
  <blockquote>
    <p>Unable to execute schema management to JDBC target [alter table
    tlp_client add constraint FKfd2km387c8s4oou769dmw5t94 foreign key
    (u_frn_address_id) references tlp_address (a_id)]</p>
  </blockquote>
  
  <p><strong>Entity</strong></p>
  
  <pre><code>@Entity
  @Table(name = "tlp_client")
  public class ClientModel {
  
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     @Column(name = "c_id")
     private Long id;
  
     @Column(name = "c_name")
     private String name;
  
     @Column(name = "c_description")
     private String description;
  
     @Column(name = "c_web_url")
     private String webUrl;
  
     @Column(name = "c_created_at")
     private Calendar createdAt;
  
     @Column(name = "c_is_active")
     private Boolean isActive;
  
     @OneToOne
     @JoinColumn(name = "u_frn_created_by", referencedColumnName = "u_id")
     private UserModel createdBy;
  
     @OneToOne
     @JoinColumn(name = "u_frn_address_id", referencedColumnName = "a_id")
     private AddressModel address;
  
      }
     // getters and setters ...
  }
  </code></pre>
  
  <p><strong>SQL for <code>ClientModel</code></strong></p>
  
  <pre><code>create table tlp_client (
     c_id INT(11) AUTO_INCREMENT,
     c_name varchar(255) NOT NULL,
     c_description varchar(255), 
     c_web_url varchar(255),
     c_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
     c_is_active TINYINT(1) DEFAULT 1,
  
     c_frn_created_by INT(11),
     c_frn_address_id INT(11),
  
     PRIMARY KEY (c_id),
     FOREIGN KEY (c_frn_address_id) REFERENCES tlp_address (a_id),
     FOREIGN KEY (c_frn_created_by) REFERENCES tlp_user (u_id)
  );
  </code></pre>
  
  <p><strong>SQL for<code>AddressModel</code></strong></p>
  
  <pre><code>create table tlp_address (
     a_id INT(11) AUTO_INCREMENT,
     a_address varchar(255),
     a_city varchar(255),
     a_state varchar(255),
     a_country varchar(255),
     a_zip varchar(8),
  
     PRIMARY KEY (a_id)
  );
  </code></pre>
  
  <p>My Question is, I have already created all the tables and still why hibernate is trying to create tables?</p>
  
  <p><strong><code>application.properties</code></strong></p>
  
  <pre><code>spring.datasource.type=com.zaxxer.hikari.HikariDataSource
  spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  spring.datasource.url=jdbc:mysql://localhost:3306/dbName?useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC
  spring.datasource.username=root
  spring.datasource.password=root
  spring.datasource.pool.size=20
  server.port=8090
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I ran the application by setting <code>spring.jpa.hibernate.ddl-auto=validate</code> in <code>application.properties</code>, now it is throwing the error</p>
  
  <blockquote>
    <p>Schema-validation: wrong column type encountered in column [a_id] in
    table [tlp_address]; found [int (Types#INTEGER)], but expecting
    [bigint (Types#BIGINT)]</p>
  </blockquote>