Skip to content
Sebastian J edited this page Mar 22, 2018 · 3 revisions

Projections are supported by the @Query annotation via DynamoDB's Projection Expressions

To use a projection, the @Query annotation must be added to the Repository interface and the desired fields must be provided (comma separated):

import org.socialsignin.spring.data.dynamodb.repository.Query;
import org.springframework.data.repository.CrudRepository;
import java.util.List;

public interface UserRepository extends CrudRepository<User, String> {

	@Query(fields = "leaveDate")
	List<User> findByPostCode(String postCode);

All attributes that are not specified in the fields list will be null - this includes the hash/range key attributes!

Note:

  • If projections are used on Global Secondary Indexes, the index must contain the desired fields in the first place (either by SELECTed attributes or via ALL)
  • This feature is available since version 5.0.3