title: Schema 'SA' does not exist and dropping table
body: <p>I am using Spring Boot to create a courses and Topics database. I am having trouble with a bunch of errors that showed up once I made changes to my Courses classes. I am not sure what's wrong. Here are the error messages:</p>
  
  <pre><code> ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: alter table course drop constraint FKokaxyfpv8p583w8yspapfb2ar
  
      ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : Schema 'SA' does not exist
  
      ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: drop table course
  
      ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : Schema 'SA' does not exist
  
      ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : HHH000389: Unsuccessful: drop table topic
  
      ERROR 1136 --- [           main] org.hibernate.tool.hbm2ddl.SchemaExport  : Schema 'SA' does not exist
  
      WARN 1136 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 10000, SQLState: 01J01
  
      WARN 1136 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   :
  </code></pre>
  
  <p>Database 'memory:testdb' not created, connection made to existing database instead.</p>
  
  <p>Also, here is my Course code, the topics code is alright I think but I am having trouble with this. I am using an internal database.</p>
  
  <p>package ...</p>
  
  <pre><code>@Entity
  
  public class Course {
      // here generate constructors and getters/setters
      @Id
      private String id;
      private String Name;
      private String description;
  
      @ManyToOne
      private Topic topic; //use it to tie this class to the Topic class, to make it easier for the user
  
      public Topic getTopic() {
          return topic;
      }
  
      public void setTopic(Topic topic) {
          this.topic = topic;
      }
  
      public Course() {
      }
  
      public Course(String id, String name, String description, String topicId) {
          super();
          this.id = id;
          Name = name;
          this.description = description;
          this.topic = new Topic(topicId,"","");
      }
  
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
      public String getName() {
          return Name;
      }
      public void setName(String name) {
          Name = name;
      }
      public String getDescription() {
          return description;
      }
      public void setDescription(String description) {
          this.description = description;
      }
  }
  </code></pre>
  
  <p>Also my Controller:</p>
  
  <pre><code>@RestController() //makes anything a rest controller, every time you build a class and add this on top of it
  public class CourseController {
  
      @Autowired // it marks the courseService as something that needs dependency inj.
      private CourseService courseService;// To create a service you need a private courseService variable
  
      //GETALL
      @RequestMapping("/topics/{id}/courses")
      public List&lt;Course&gt; getAllcourses(@PathVariable String id){
          return courseService.getAllCourses(id);  //getAllCourses for the topic ID
      }
      //GET
      @RequestMapping("/topics/{topicId}/courses/{id}") 
  
      public Course getCourse(@PathVariable String id) {
          return courseService.getCourse(id);
      }
  
      //POST
      @RequestMapping(method = RequestMethod.POST, value = "/topics/{topicId}/courses")
      public void addCourse(@RequestBody Course course, @PathVariable String topicId) { 
          course.setTopic(new Topic(topicId, "", ""));
          courseService.addCourse(course);
      }
  
      //PUT
      @RequestMapping(method = RequestMethod.PUT, value = "/topics/{topicId}/courses/{id}")
      public void updateCourse(@RequestBody Course course,  @PathVariable String id,  @PathVariable String topicId) { 
          course.setTopic(new Topic(topicId, "", ""));
          courseService.updateCourse(course);
  
      }
      //DELETE
      @RequestMapping(method = RequestMethod.DELETE, value = "/topics/{topicId}/courses/{id}")
      public void deletecourse(@PathVariable String id, @PathVariable String topicId) {
          courseService.deleteCourse(id);
  
      }
  }
  </code></pre>
  
  <p>And finally my Service class:</p>
  
  <pre><code>package io.msela.springbootstarter.course;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  @Service
  public class CourseService {
  
      @Autowired // it injects the courseRepository as it's initialized
      private CourseRepository courseRepository;
  
      public List&lt;Course&gt; getAllCourses(String topicId){ //getting all is not good!
          List&lt;Course&gt; courses = new ArrayList&lt;&gt;() ;
          courseRepository.findByTopicId(topicId).forEach(courses::add);
          return courses;
      }
  
      public Course getCourse(String id) {
          return courseRepository.findOne(id);
      }
  
      public void addCourse(Course course) {
          courseRepository.save(course); //save a course to the database
              }
  
      public void updateCourse(Course course) {
          courseRepository.save(course);
          //save does both add and update
          }
  
  
      public void deleteCourse(String id) {
          courseRepository.delete(id);
      }
  }
  </code></pre>
  
  <p>EDIT: Here's my pom.xml file as well</p>
  
  <p>
  http://maven.apache.org/xsd/maven-4.0.0.xsd">
      4.0.0</p>
  
  <pre><code>&lt;groupId&gt;io.msela&lt;/groupId&gt;
  &lt;artifactId&gt;course-api-data&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;course-api-data&lt;/name&gt;
  &lt;description&gt;Course API with Spring Data&lt;/description&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.5.4.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.derby&lt;/groupId&gt;
          &lt;artifactId&gt;derby&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>The Actual error seems to be the following:</p>
  
  <blockquote>
    <p>Exception encountered during context initialization - cancelling
    refresh attempt:
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'courseController': Unsatisfied
    dependency expressed through field 'courseService'; nested exception
    is org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'courseService': Unsatisfied dependency
    expressed through field 'courseRepository'; nested exception is
    org.springframework.beans.factory.BeanCreationException: Error
    creating bean with name 'courseRepository': Invocation of init method
    failed; nested exception is java.lang.IllegalArgumentException: Could
    not create query metamodel for method public abstract java.util.List
    io.msela.springbootstarter.course.CourseRepository.findByName(java.lang.String)!</p>
  </blockquote>