Comment écrire Printemps de Données nom de la méthode pour récupérer tous les éléments dans une colonne?

Supposons que j'ai la classe:

@Entity
public class Bean {
    @Id
    private String beanId;
    //other fields & setters and getters
}

Et le Printemps de Données JPA référentiel, où j'ai envie d'avoir dans un List<String> tous les beanIds.

@RepositoryDefinition(domainClass = Bean.class, idClass = String.class)
public interface BeanRepository {
    @Query("select b.beanId from Bean b")
    List<String> findAllBeanId();
}

Comme écrit ci-dessus, tout fonctionne comme prévu; mais c'est une opération simple et je ne veux pas écrire une requête explicite. Quel doit être le nom de la méthode, tels que le Printemps de Données peut l'analyser et d'en obtenir le ci-dessus mentionné requête (ou les mêmes fonctionnalités). J'ai cherché dans les deux à la documentation de référence comme les deux livres que j'ai sur le Printemps de Données. Le nom ci-dessus (findAllBeanId) et d'autres que j'ai essayé (findBeanId, findBeanBeanId etc.) jeter l'exception suivante en tant que root cause:

org.springframework.data.mapping.PropertyReferenceException: No property find found for type Trade
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:72)
at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180)
at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260)
at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240)
at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68)
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:279)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 22 more

OriginalL'auteur m3th0dman | 2013-08-09