title: Hibernate: Why am I getting an empty json?
body: <p>I have a simple entity class:</p>
  <pre><code>@Entity(name = &quot;User&quot;)
  @Table(name = &quot;users&quot;)
  @Data
  @NoArgsConstructor
  public class User {
  
      @Id
      @GeneratedValue
      private Long id;
      private String name;
      private Integer age;
      private String email;
  }
  </code></pre>
  <p>A repository:</p>
  <pre><code>@Repository
  public interface UserRepository extends CrudRepository&lt;User, Long&gt; {
  
  }
  </code></pre>
  <p>A service:</p>
  <pre><code>@Service
  public class UserService {
  
      private final UserRepository userRepository;
  
      public UserService(UserRepository userRepository) {
          this.userRepository = userRepository;
      }
  
      public Iterable&lt;User&gt; findAllUsers() {
          return userRepository.findAll();
      }
  
      public &lt;U extends User&gt; void saveUser(U user) {
          userRepository.save(user);
      }
  }
  </code></pre>
  <p>A controller:</p>
  <pre><code>@RestController
  @RequestMapping(&quot;api/v1/users&quot;)
  public class UserController {
  
      private final UserService userService;
  
      public UserController(UserService userService) {
          this.userService = userService;
      }
  
      @GetMapping
      public Iterable&lt;User&gt; getAllUsers() {
          return userService.findAllUsers();
      }
   
      @PostMapping
      public void addUser(@RequestBody User user) {
          userService.saveUser(user);
      }
  }
  </code></pre>
  <p>And a yaml file:</p>
  <pre><code>spring:
    datasource:
      username: &quot;root&quot;
      password: &quot;123123&quot;
      url: &quot;jdbc:mysql://localhost:3306/mydbtest&quot;
      driverClassName: &quot;com.mysql.jdbc.Driver&quot;
    jpa:
      hibernate.ddl-auto: update
      generate-ddl: true
      show-sql: true
  </code></pre>
  <p>I use MYSQL Workbench, where I have a database with one table called users. Sending a get request and trying to get all the objects from the table, I get an empty json. What should I do?</p>