title: Spring boot post api - org.postgresql.util.PSQLException: ERROR: null value in column "password" violates not-null constraint
body: <p>I have created a spring boot application. And in the application I'm working with API's. I have an POST API for creating an user, but every time I use the api, i will get the following error</p>
  <pre><code>Spring boot post api - org.postgresql.util.PSQLException: ERROR: null value in column &quot;password&quot; violates not-null constraint
  </code></pre>
  <p>Im using hibernate and PostgreSQL as database.</p>
  <p>Even if I give de data values, i will get this error. I searched over the internet, but I cant find a solution for this problem</p>
  <p>This is the code that i user:</p>
  <p>Users.java:</p>
  <pre><code>@Entity
  @NoArgsConstructor
  @AllArgsConstructor
  @Getter
  @Setter
  @Builder(toBuilder = true)
  @ToString
  @Table
  public class Users {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int user_id;
      @Column(unique = true, nullable = false)
      private String username;
      @Column(nullable = false)
      private String password;
  }
  </code></pre>
  <p>UsersRepository.java</p>
  <pre><code>@Repository
  public interface UsersRepository extends JpaRepository&lt;Users, Integer&gt; {}
  </code></pre>
  <p>UsersService</p>
  <pre><code>@Service
  @RequiredArgsConstructor
  @Transactional
  public class UsersService {
      private final UsersRepository usersRepository;
  
      public Users createUser(Users newUsers) {
          return this.usersRepository.save(newUsers);
      }
  }
  </code></pre>
  <p>UsersDto</p>
  <pre><code>@Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  public class UsersDto {
      private int user_id;
      private String username;
      private String password;
  }
  </code></pre>
  <p>UsersMapper</p>
  <pre><code>@Mapper(componentModel = &quot;spring&quot;, unmappedTargetPolicy = ReportingPolicy.IGNORE)
  public interface UsersMapper {
      UsersDto toDto(Users users);
      Users toModel(UsersDto usersDto);
  }
  </code></pre>
  <p>UsersController</p>
  <pre><code>@RestController
  @CrossOrigin(origins = &quot;http://localhost:4200&quot;)
  @RequiredArgsConstructor
  @RequestMapping(&quot;/users&quot;)
  @Validated
  public class UsersController {
      private final UsersService usersService;
      private final UsersMapper usersMapper;
  
      @PostMapping()
      @ApiOperation(value = &quot;Create new user&quot;, httpMethod = &quot;POST&quot;, code = 201)
      @ResponseBody
      public ResponseEntity&lt;UsersDto&gt; createUser(@RequestBody UsersDto usersDto) throws Exception {
          Users users = this.usersMapper.toModel(usersDto);
          Users createUsers = this.usersService.createUser(users);
          return ResponseEntity.ok(this.usersMapper.toDto(createUsers));
      }
  }
  </code></pre>
  <p>I hope someone can help me with this problem</p>