How can spring data jpa query only some of the fields and not return all of them?

suppose I create a new user with four fields, id, user name, password, and address.
how does spring data jpa query only the username and password fields?
(the actual developed table has more than 20 fields, and it takes 12 seconds for a query to return all fields of a month"s record, but my requirement only needs three fields in the table, and it only takes 0.0083s for a sql query to return a month"s record)

Sep.08,2021

use spring-data 's projection:

public interface UserDto {
  Integer getId();
  String getUsername();
  String getPassword();
}

public interface UserRepository extends JpaRepository<User, Integer> {
  // smart way
  List<UserDto> findBy...(...);

  // 
  @Query("select id, username, password from User where ...")
  List<UserDto> findUserDto(...);
}

  // smart way
  List<UserDto> findBy...(...);

does this method return all fields?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46396-44b9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46396-44b9a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?