I have seen this and I have similar problem, but I would like to get only two from four fields - for example: only id and name from id, name, dateOfBirth, weight.
public interface ICatDAO extends CrudRepository<Cat,Long> {
@Query(value = "SELECT c.id, c.name FROM Cat c")
public List<Cat> findAll();
//...
}
If I use query: @Query(value = "SELECT c FROM Cat c") I get objects list type 'Cat', but with all fields.
If I use query: @Query(value = "SELECT c.id, c.name FROM Cat c") I get object list type 'Object' and this is the problem. What should I do in this case?