title: Spring boot queries wrong table
body: <p>I'm new to spring boot and I'm currently following this tutorial(<a href="https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/" rel="nofollow noreferrer">https://www.callicoder.com/spring-boot-rest-api-tutorial-with-mysql-jpa-hibernate/</a>). I've managed to create a api which can query table for getAll and addOne. Problem is that it doesnt use existing table on these queries. Instead my code generates new table and executes queries in that table.. How to configure my project that it uses my original table?</p>
  
  <p>Database table which I'd like to use as datasource in this example. I have one row of data already stored in this table.</p>
  
  <pre><code>mysql&gt; show columns from palauteUser;
  +-----------+-------------+------+-----+---------+-------+
  | Field     | Type        | Null | Key | Default | Extra |
  +-----------+-------------+------+-----+---------+-------+
  | userUUID  | varchar(30) | NO   | PRI | NULL    |       |
  | firstName | varchar(30) | YES  |     | NULL    |       |
  | lastName  | varchar(30) | YES  |     | NULL    |       |
  | email     | varchar(30) | YES  |     | NULL    |       |
  +-----------+-------------+------+-----+---------+-------+
  </code></pre>
  
  <p>Database table generated by spring boot </p>
  
  <pre><code>mysql&gt; show columns from palaute_user;
  +------------+--------------+------+-----+---------+-------+
  | Field      | Type         | Null | Key | Default | Extra |
  +------------+--------------+------+-----+---------+-------+
  | useruuid   | varchar(255) | NO   | PRI | NULL    |       |
  | email      | varchar(255) | YES  |     | NULL    |       |
  | first_name | varchar(255) | YES  |     | NULL    |       |
  | last_name  | varchar(255) | YES  |     | NULL    |       |
  +------------+--------------+------+-----+---------+-------+
  </code></pre>
  
  <p>Projects pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;fi.oppari.mysql.service&lt;/groupId&gt;
      &lt;artifactId&gt;SpringService&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;SpringService&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&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;2.0.3.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.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&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;
  
  
  &lt;/project&gt;
  </code></pre>
  
  <p>application.properties file</p>
  
  <pre><code>## Spring DATASOURCE (DataSourceAutoConfiguration &amp; DataSourceProperties)
  spring.datasource.url = jdbc:mysql://localhost:3306/oppariDB?useSSL=false
  spring.datasource.username = root
  spring.datasource.password = root
  
  spring.jpa.show-sql=true
  
  ## Hibernate Properties
  # The SQL dialect makes Hibernate generate better SQL for the chosen database
  spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
  
  # Hibernate ddl auto (create, create-drop, validate, update)
  spring.jpa.hibernate.ddl-auto = update
  server.port=9090
  </code></pre>
  
  <p>Model class</p>
  
  <pre><code>package fi.oppari.mysql.service.SpringService.model;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  
  
  @Entity
  @Table(name = "palauteUser")
  public class PalauteUser {
  
      @Id
      private String userUUID;
  
      @Column(name = "firstName")
      private String firstName;
  
      @Column(name = "lastName")
      private String lastName;
  
      @Column(name = "email") 
      private String email;
  
      public String getUserUUID() {
          return userUUID;
      }
  
      public void setUserUUID(String userUUID) {
          this.userUUID = userUUID;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
  }
  </code></pre>
  
  <p>Repository interface:</p>
  
  <pre><code>package fi.oppari.mysql.service.SpringService.repository;
  
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  import fi.oppari.mysql.service.SpringService.model.PalauteUser;
  
  @Repository
  public interface PalauteUserRepository extends JpaRepository&lt;PalauteUser, String&gt;{
  
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>package fi.oppari.mysql.service.SpringService.controller;
  
  import java.util.List;
  
  import javax.validation.Valid;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  import fi.oppari.mysql.service.SpringService.model.PalauteUser;
  import fi.oppari.mysql.service.SpringService.repository.PalauteUserRepository;
  
  @RestController
  @RequestMapping("/api")
  public class PalauteUserController {
  
      @Autowired
      PalauteUserRepository palauteUserRepository;
  
      @GetMapping("/all")
      public List&lt;PalauteUser&gt; getAll() {
          System.out.println("Getting all");
          return palauteUserRepository.findAll();
      }
  
      @PostMapping("/addOne")
      public PalauteUser addUser(@Valid @RequestBody PalauteUser user) {
          return palauteUserRepository.save(user);
      }
  
  }
  </code></pre>
  
  <p>After mvn spring-boot:run command I use postman with GET localhost:9090/api/all which returns empty array. POST localhost:9090/api/addOne with json data is also success and it adds information to palaute_user table.</p>
  
  <p>Any advices are welcome for this problem and I thank in advance for them! :)</p>