title: Table does not exist in mysql database
body: <blockquote>
  <p>I use JPA for database, I properly define one to many and one to one
  join in my entity class but it is not able to create table for my
  receipt entity class . I do not understand where I make mistake. I
  complete check the entity class but I am not able to find my mistake.
  Below type of error I get when run the application.</p>
  </blockquote>
  <pre><code>org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL &quot;alter table receipt add constraint FK57qulpfkyxvba4mmdup6l3vot foreign key (problem_id) references disease (problem_id)&quot; via JDBC Statement
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:562) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:507) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:318) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.10.jar:5.3.10]
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.10.jar:5.3.10]
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.10.jar:5.3.10]
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.10.jar:5.3.10]
      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.10.jar:5.3.10]
      at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.10.jar:5.3.10]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.10.jar:5.3.10]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.10.jar:5.3.10]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.5.jar:2.5.5]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.5.jar:2.5.5]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.5.jar:2.5.5]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.5.jar:2.5.5]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.5.jar:2.5.5]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.5.jar:2.5.5]
      at com.nillmani.hospitalmanagement.HospitalManagementApplicationKt.main(HospitalManagementApplication.kt:13) ~[main/:na]
  Caused by: java.sql.SQLSyntaxErrorException: Table 'hospital-management.receipt' doesn't exist
      at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.26.jar:8.0.26]
      at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.26.jar:8.0.26]
      at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:764) ~[mysql-connector-java-8.0.26.jar:8.0.26]
      at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648) ~[mysql-connector-java-8.0.26.jar:8.0.26]
      at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-4.0.3.jar:na]
      at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-4.0.3.jar:na]
      at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
      ... 33 common frames omitted
  </code></pre>
  <blockquote>
  <p>Receipt.kt</p>
  </blockquote>
  <pre><code>package com.nillmani.hospitalmanagement.entity
  
  import java.time.LocalDate
  import javax.persistence.*
  
  @Entity
  data class Receipt(
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      val receipeId:Long=-1,
      val details :String=&quot;&quot;,
      val barcode : String =&quot;&quot;,
      val drug_details: String=&quot;&quot;,
      val usage : String =&quot;&quot;,
      val delivery_Date : LocalDate= LocalDate.now(),
      val diseaseId:Long=-1,//refere to  problmeID
      val patientId:Long=-1,
      val status : Int=0,
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = &quot;problemId&quot;,referencedColumnName = &quot;problemId&quot;)
      val disease: Disease
  )
  </code></pre>
  <blockquote>
  <p>Disease.kt</p>
  </blockquote>
  <pre><code>package com.nillmani.hospitalmanagement.entity
  
  import com.nillmani.hospitalmanagement.entity.enum.ProblemStatus
  import org.jetbrains.annotations.NotNull
  import javax.persistence.*
  
  @Entity
  data class Disease(
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      val problemId:Long=-1,
      val diseaseName:String=&quot;&quot;,
      val diseaseDetails:String=&quot;&quot;,
      val problemStatus : ProblemStatus,
      var status : Int=0,
      val seekPersonId : Long=-1,//Basically Belongs form patientID
      val admissionId : Long =-1,
      @NotNull
      @ManyToOne(cascade = [CascadeType.ALL],fetch = FetchType.LAZY)
      @JoinColumn(name = &quot;patientid&quot;,referencedColumnName = &quot;patientid&quot;)
      val patient: Patient,
      @OneToMany(cascade = [CascadeType.ALL],fetch = FetchType.LAZY,mappedBy = &quot;disease&quot;)
      val receipes :List&lt;Receipt&gt; = ArrayList()
  )
  </code></pre>
  <blockquote>
  <p>I provide join between these two table ,but every entity class exist
  in database but receipt entity class not able to exist in database.
  what is the reason for this type of issue
  application.yml</p>
  </blockquote>
  <pre><code>spring:
    datasource:
      url: jdbc:mysql://localhost:3307/hospital-management
      driverClassName: com.mysql.cj.jdbc.Driver
      username: root
      password:
    jpa:
      database-platform: org.hibernate.dialect.MySQL5Dialect
      show-sql: true
      hibernate:
        ddl-auto: update
      generate-ddl: true
  
  app:
    jwt:
      secret: ArbitrarySecretKey
  
      expiration-in-ms: 864000000
      token:
        prefix: Bearer
      header:
        string: Authorization
  </code></pre>
  <blockquote>
  <p>application.properties</p>
  </blockquote>
  <pre><code>logging.level.org.hibernate.SQL=debug
  </code></pre>