{"action":"created","issue":{"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/162","repository_url":"https://api.github.com/repos/derjust/spring-data-dynamodb","labels_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/162/comments","events_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/162/events","html_url":"https://github.com/derjust/spring-data-dynamodb/issues/162","id":320475748,"node_id":"MDU6SXNzdWUzMjA0NzU3NDg=","number":162,"title":"findAllByAttributeStartingWith requires @EnableScan even when attribute is a GSI Hash Key","user":{"login":"parxier","id":1980968,"node_id":"MDQ6VXNlcjE5ODA5Njg=","avatar_url":"https://avatars2.githubusercontent.com/u/1980968?v=4","gravatar_id":"","url":"https://api.github.com/users/parxier","html_url":"https://github.com/parxier","followers_url":"https://api.github.com/users/parxier/followers","following_url":"https://api.github.com/users/parxier/following{/other_user}","gists_url":"https://api.github.com/users/parxier/gists{/gist_id}","starred_url":"https://api.github.com/users/parxier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parxier/subscriptions","organizations_url":"https://api.github.com/users/parxier/orgs","repos_url":"https://api.github.com/users/parxier/repos","events_url":"https://api.github.com/users/parxier/events{/privacy}","received_events_url":"https://api.github.com/users/parxier/received_events","type":"User","site_admin":false},"labels":[{"id":196423229,"node_id":"MDU6TGFiZWwxOTY0MjMyMjk=","url":"https://api.github.com/repos/derjust/spring-data-dynamodb/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-05T03:29:30Z","updated_at":"2018-06-25T08:03:00Z","closed_at":null,"author_association":"NONE","body":"## Expected Behavior\r\nAs per https://github.com/derjust/spring-data-dynamodb/wiki/Supported-Spring-Data-Comparison-Operators assumption is that `STARTING_WITH` is supported without need for a `@EnableScan`.\r\n\r\nExpected Behavior is that `List<Entity> findAllByAttributeStartingWith(String attributePrefix)` will use GSI and not fall back to Scan.\r\n\r\n## Actual Behavior\r\nException is thrown:\r\n```\r\njava.lang.IllegalArgumentException: Scanning for this query is not enabled.  To enable annotate your repository method with @EnableScan, or enable scanning for all repository methods by annotating your repository interface with @EnableScan\r\n\r\n\tat org.springframework.util.Assert.isTrue(Assert.java:116)\r\n\tat org.socialsignin.spring.data.dynamodb.query.MultipleEntityScanExpressionQuery.assertScanEnabled(MultipleEntityScanExpressionQuery.java:41)\r\n\tat org.socialsignin.spring.data.dynamodb.query.MultipleEntityScanExpressionQuery.getResultList(MultipleEntityScanExpressionQuery.java:35)\r\n```\r\n\r\n`findAllByAttribute(String attribute)` works as expected and returns list of entities with exact match.\r\n\r\n## Steps to Reproduce the Problem\r\n\r\n  1. Add GSI Hash Key attribute:\r\n```\r\n    @DynamoDBIndexHashKey(globalSecondaryIndexName = \"AttributeIndex\")\r\n    @DynamoDBAttribute\r\n    private String attribute;\r\n```\r\n  2. Add repository method:\r\n```\r\nList<Entity> findAllByAttributeStartingWith(String attributePrefix);\r\n```\r\n  3. Executing that method causes `IllegalArgumentException` asking for `@EnableScan` annotation.\r\n\r\n## Specifications\r\n  \r\n  - Spring Data DynamoDB Version: 5.0.2 (2.0)\r\n  - Spring Data Version: 2.0.6.RELEASE\r\n  - AWS SDK Version: 1.11.312\r\n  - Java Version: 1.8.0_162 - Java HotSpot(TM) 64-Bit Server VM 25.162-b12\r\n  - Platform Details: Mac OS X 10.13.4\r\n"},"comment":{"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/comments/399866812","html_url":"https://github.com/derjust/spring-data-dynamodb/issues/162#issuecomment-399866812","issue_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/162","id":399866812,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTg2NjgxMg==","user":{"login":"engrun","id":729126,"node_id":"MDQ6VXNlcjcyOTEyNg==","avatar_url":"https://avatars0.githubusercontent.com/u/729126?v=4","gravatar_id":"","url":"https://api.github.com/users/engrun","html_url":"https://github.com/engrun","followers_url":"https://api.github.com/users/engrun/followers","following_url":"https://api.github.com/users/engrun/following{/other_user}","gists_url":"https://api.github.com/users/engrun/gists{/gist_id}","starred_url":"https://api.github.com/users/engrun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/engrun/subscriptions","organizations_url":"https://api.github.com/users/engrun/orgs","repos_url":"https://api.github.com/users/engrun/repos","events_url":"https://api.github.com/users/engrun/events{/privacy}","received_events_url":"https://api.github.com/users/engrun/received_events","type":"User","site_admin":false},"created_at":"2018-06-25T08:03:00Z","updated_at":"2018-06-25T08:03:00Z","author_association":"NONE","body":"I think I have stumbled across a related issue. \r\nUsing the strategy for  [paging](https://github.com/derjust/spring-data-dynamodb/wiki/Query-Size-Limits-and-Pageable), I still have to annotate my `findBy*` methods with `@EnableScan`\r\n\r\nthe error is:\r\n\r\n```\r\njava.lang.IllegalArgumentException: Scanning for this query is not enabled.  To enable annotate your repository method with @EnableScan, or enable scanning for all repository methods by annotating your repository interface with @EnableScan\r\n        at org.springframework.util.Assert.isTrue(Assert.java:116)\r\n        at org.socialsignin.spring.data.dynamodb.query.MultipleEntityScanExpressionQuery.assertScanEnabled(MultipleEntityScanExpressionQuery.java:41)\r\n        at org.socialsignin.spring.data.dynamodb.query.MultipleEntityScanExpressionQuery.getResultList(MultipleEntityScanExpressionQuery.java:35)\r\n        at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQuery$PagedExecution.execute(AbstractDynamoDBQuery.java:161)\r\n        at org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQuery.execute(AbstractDynamoDBQuery.java:303)\r\n        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:590)\r\n```"}}
{"actor":{"display_login":"engrun"}}