title: Spring Boot+Hibernate insert null values to mysql
body: <p>I've got configuration like this (using Maven):</p>
  
  <p>pom.xml</p>
  
  <pre><code>&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;springbootPlural&lt;/groupId&gt;
    &lt;artifactId&gt;das-boot&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
  
    &lt;name&gt;das-boot&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&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.2.RELEASE&lt;/version&gt;
      &lt;relativePath/&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;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&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-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;mysql&lt;/groupId&gt;
        &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
        &lt;version&gt;5.1.39&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>server.port=0 #(for random port)
  
  spring.jpa.hibernate.ddl-auto=update
  spring.jpa.show-sql=true
  spring.datasource.url=jdbc:mysql://localhost:3306/mojabaza
  spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  spring.datasource.username=root
  spring.datasource.password=root
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  
  User.class
  package com.test.testowa.model;
  
  import org.springframework.data.jpa.domain.AbstractPersistable;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  
  @Entity
  public class User extends AbstractPersistable&lt;Long&gt; {
  
      private String userId;
      private String userName;
      private String password;
  
      public User() {
  
      }
  
  
      public User(String userId, String userName, String password) {
          this.userId = userId;
          this.userName = userName;
          this.password = password;
      }
  
      public String getUserId() {
          return userId;
      }
  
      public void setUserId(String userId) {
          this.userId = userId;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  }
  </code></pre>
  
  <p>UserController.class</p>
  
  <pre><code>package com.test.testowa.controller;
  
  import com.test.testowa.Service.UserService;
  import com.test.testowa.model.User;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  import java.util.List;
  
  @RestController
  @RequestMapping("/user")
  public class UserController {
      private UserService userService;
  
      @Autowired
      public UserController(UserService userService) {
          this.userService = userService;
      }
  
  
      @RequestMapping("/delete/{id}")
      public String deleteUser(@PathVariable Long id)
      {
          return userService.deleteUser(id);
      }
  
  
      @RequestMapping("/add")
      public User addUser(User user)
      {
          return userService.addUser(user);
      }
  
  
      @RequestMapping("/list/{id}")
      public User findOne(@PathVariable Long id)
      {
  
          return userService.findOne(id);
      }
  
      @RequestMapping("/list")
      public List&lt;User&gt; userList()
      {
          return userService.userList();
      }
  
  
  
  }
  </code></pre>
  
  <p>UserServiceImpl.class</p>
  
  <pre><code>package com.test.testowa.Service.impl;
  
  import com.test.testowa.Service.UserService;
  import com.test.testowa.model.User;
  import com.test.testowa.repository.UserRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  
  @Service
  public class UserServiceImpl implements UserService {
  
  private UserRepository userRepository;
  
  @Autowired
      public UserServiceImpl(UserRepository userRepository) {
          this.userRepository = userRepository;
      }
  
      @Override
      public List&lt;User&gt; userList() {
          return userRepository.findAll();
      }
  
  
      @Override
      public User findOne(Long id) {
          return userRepository.findOne(id);
      }
  
      @Override
      public User addUser(User user) {
          return userRepository.save(user);
      }
  
      @Override
      public String deleteUser(Long id) {
          userRepository.delete(id);
      return "{'message':'User deleted'}";
      }
  }
  </code></pre>
  
  <p>UserRepository.class</p>
  
  <pre><code>package com.test.testowa.repository;
  
  import com.test.testowa.model.User;
  import org.springframework.data.jpa.repository.JpaRepository;
  
  public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
  
  
  }
  </code></pre>
  
  <p>UserService.class</p>
  
  <p>package com.test.testowa.Service;</p>
  
  <pre><code>import com.test.testowa.model.User;
  
  import java.util.List;
  
  public interface UserService {
      List&lt;User&gt; userList();
      User findOne(Long id);
  
      User addUser(User user);
      String deleteUser(Long id);
  }
  </code></pre>
  
  <p>Hibernate creates table "user" flawlessly, but when I'm inserting some values in Postman e.g POST -> localhost:43441/shipwrecks/add, with application/json header and body:</p>
  
  <pre><code>{
  "id2":1,
  "name":"name1",
  "description":"desc1"
  }
  </code></pre>
  
  <p>And I'm getting: <code>Hibernate: insert into shipwreck (description, id2, name) values (?, ?, ?)</code> in console. When I'm inserting data in mysql manually everything go well. Also GET ->localhost:43563/shipwrecks/list works well. Did I make a mistake in this code? Maybe wrong version of Spring Boot?</p>