Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Method name query derivation on findAll with a sort clause

$
0
0
Hello,

I have a Maven build on a Spring Data JPA project with some integration tests against the MySQL database.

I have a query to sort all records of a table.

The following works fine and the integration test is successful:

@Query("SELECT a FROM Admin a ORDER BY a.lastname ASC, a.firstname ASC")
public Page<Admin> findAll(Pageable page);

But if I replace the above finder by the following one:

public Page<Admin> findAllOrderByLastnameAscFirstnameAsc(Pageable page);

then I get an error message:

Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'adminRepositoryImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: private com.thalasoft.learnintouch.core.jpa.repository.Adm inRepository com.thalasoft.learnintouch.core.jpa.repository.Adm inRepositoryImpl.adminRepository; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'adminRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReference Exception: No property asc found for type java.lang.String

And I wonder what is happening here...

Kind Regards,

Viewing all articles
Browse latest Browse all 297

Trending Articles