You can use projections from Spring Data JPA (doc). In your case, create interface:
interface ProjectIdAndName{
String getId();
String getName();
}
and add following method to your repository
List<ProjectIdAndName> findAll();
More Related Contents:
- How to properly use findBySomeOtherId not findById in Spring data jpa?
- setMaxResults for Spring-Data-JPA annotation?
- Using generics in Spring Data JPA repositories
- Spring Data JPA – ZonedDateTime format for json serialization
- How does the FetchMode work in Spring Data JPA
- Spring Data JPA – “No Property Found for Type” Exception
- How do I update an entity using spring-data-jpa?
- ImprovedNamingStrategy no longer working in Hibernate 5
- Spring CrudRepository findByInventoryIds(List inventoryIdList) – equivalent to IN clause
- Spring data jpa- No bean named ‘entityManagerFactory’ is defined; Injection of autowired dependencies failed
- Spring boot JPA insert in TABLE with uppercase name with Hibernate
- Can I combine a @Query definition with a Specification in a Spring Data JPA repository method?
- JPA: update only specific fields
- Spring-Data FETCH JOIN with Paging is not working
- Refresh and fetch an entity after save (JPA/Spring Data/Hibernate)
- Why use returned instance after save() on Spring Data JPA Repository?
- Spring JpaRepository – Detach and Attach entity
- Use abstract super class as parameter for Spring data repository
- Are you supposed to have one repository per table in JPA?
- How to map sql native query result into DTO in spring jpa repository?
- Spring-boot: required a bean named ‘entityManagerFactory’ that could not be found
- Difference between save and saveAndFlush in Spring data jpa
- Delete Not Working with JpaRepository
- %Like% Query in spring JpaRepository
- spring data jpa @query and pageable
- JPQL Like Case Insensitive
- Spring Data JPA: query ManyToMany
- Spring Data JPA find by embedded object property
- Why has javax.persistence-api been replaced by jakarta.persistence-api in spring data jpa starter?
- Spring Data + JPA with multiple datasources but only one set of Repositories