2

for example i have Repository class :

public interface PersonRepo extends JpaRepository<Person, Long>, JpaSpecificationExecutor<Person>

and i want to use findAll() method provided by JpaSpecificationExecutor.

if i want to get all users it returns full user DTO-s including encripted passwords and user roles etc...

PersonRepo.findAll()

How can i tell findAll to send only name and email for example instead of everything.

I use Mapstruct to convert my Person Class to PersonDTO.

giliermo
  • 141
  • 1
  • 8
  • Leave findAll() as it is . You can create your method that calls findAll() and stores in local List. Then you can filter what you want and return new List – bakero98 Mar 12 '20 at 14:41

1 Answers1

3

As mentioned here, you will have to define your own method and use the @Query annotation for it.

Tarek Badr
  • 847
  • 9
  • 12