title: JPA repository save method inserts NULL values in MySQL instead of values provided by json request
body: <p>I'm new to spring. I want to add a row in MySQL database by a post request using POSTMAN via Spring boot project.
  <br>
  I send a post request with a json body providing neccessary values for the table. but when I check the table I see that NULL values are inserted in table. Can you please help me prevent inserting null values in table.<br>
  CODE<br>
  AuthConroller.java Class<br></p>
  <pre><code>import com.hackernewsclient.com.hackernewsclient.dto.ResgisterRequest;
  import com.hackernewsclient.com.hackernewsclient.service.AuthService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  
  import org.springframework.web.bind.annotation.*;
  
  @RestController
  @RequestMapping(&quot;/api/auth&quot;)
  public class AuthController {
  
  
      @Autowired
      private AuthService authService;
  
      @PostMapping(&quot;/signup&quot;)
      public ResponseEntity signup(@RequestBody ResgisterRequest resgisterRequest) {
          authService.signup(resgisterRequest);
          return new ResponseEntity(HttpStatus.OK);
      }
  
  }
  </code></pre>
  <br>
  User.java entity class<br>
  <pre><code>import javax.persistence.*;
  
  @Entity
  @Table(name = &quot;user&quot;)
  public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
      @Column
      private String userName;
      @Column
      private String password;
      @Column
      private String email;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      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;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
  }
  </code></pre>
  <br>
  AuthService.java class<br>
  <pre><code>import com.hackernewsclient.com.hackernewsclient.dto.ResgisterRequest;
  import com.hackernewsclient.com.hackernewsclient.model.User;
  import com.hackernewsclient.com.hackernewsclient.repository.UserRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  @Service
  public class AuthService {
  
      @Autowired
      private UserRepository userRepository;
  
      public void signup(ResgisterRequest resgisterRequest) {
          User user = new User();
          user.setUserName(resgisterRequest.getUsername());
          user.setPassword(resgisterRequest.getPassword());
          user.setEmail(resgisterRequest.getEmail());
          userRepository.save(user);
      }
      
  }
  </code></pre>
  <br>
  UserRepository.java interface<br>
  <pre><code>import com.hackernewsclient.com.hackernewsclient.model.User;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface UserRepository extends JpaRepository&lt;User,Long&gt; {
  }
  </code></pre>
  <br>
  RegisterRequest.java Data Object class for post request's body<br>
  <pre><code>public class ResgisterRequest {
  
      private String user_name;
      private String password;
      private String email;
  
      public String getUsername() {
          return user_name;
      }
  
      public void setUsername(String username) {
          username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          password = password;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          email = email;
      }
  }
  </code></pre>
  <br>
  Screenshot of POSTMAN - my request attempt which its status is successful
  <br>
  <img src="https://i.stack.imgur.com/IRVuR.jpg">
  <br>
  Screenshot of User table values in MySQL phpmyadmin
  <br>
  <img src="https://i.stack.imgur.com/E0RZ2.jpg">
  <br>
  Intellij Log
  <br>
  <pre><code>Hibernate: insert into user (email, password, user_name) values (?, ?, ?)
  </code></pre>