Open spring-projects-issues opened 6 years ago
Oliver Drotbohm commented
Can you clarify what you mean exactly? The title says Pageable
, the description talks about projections. If it's the latter, it would be interesting what exactly you're missing as the section on projections is quite extensive already
Manuel Jordan commented
Title's fixed. Sorry for the confusion.
In the 4.3.11. Projections
section does not appear a sample about this:
/**
* Projection interfaces can be used with manually declared queries, too. Make sure you alias the projects matching
* the projection fields.
*
* @return
*/
@Query("select c.firstname as firstname, c.lastname as lastname from Customer c")
Collection<CustomerProjection> findsByProjectedColumns();
Thus from above there is neither sample code nor explanation about a projection being returned and working with @Query
Other case not covered is:
/**
* Projections used with pagination.
*
* @param pageable
* @return
*/
Page<CustomerProjection> findPagedProjectedBy(Pageable pageable);
Thus from above there is neither sample code nor explanation about a projection being returned and working with Pageable
And finally a 'fusion' from of both above:
/**
* Projection interfaces can be used with manually declared queries, too. Make sure you alias the projects matching
* the projection fields.
*
* @return
*/
@Query("select c.firstname as firstname, c.lastname as lastname from Customer c")
Collection<CustomerProjection> findsByProjectedColumns(Pageable pageable);
Returning a projection and using a @Query
and Pageable
together.
I hope all is clear now, it to complement the current documentation
Oliver Drotbohm commented
I can see that we need to drop a word about the aliases, but there's absolutely nothing projection specific about the pagination. It just works as usual
Manuel Jordan commented
There is no a sample about the following combination:
@Query("SELECT p.id as id, p.nombre as nombre, p.apellido as apellido, p.fecha as fecha FROM Persona p")
Page<PersonaProjection> findAllProjectedBy(Pageable pageable);
and indicating that each as
is mandatory (such your javadoc
indicates).
Perhaps I am confused about project interface
because I am assuming it is working or being using because I see the PersonaProjection
object in the return type (Page<PersonaProjection>
)
Even if you are correct, well there is a missing scenario to be included
Manuel Jordan opened DATACMNS-1310 and commented
Currently there is no documentation about
projection interface
working together with@Query
.In the link shared about SO, it does mention about the CustomerRepository.java class and exists many samples variations there including one about this request
Affects: 2.0.6 (Kay SR6)
Reference URL: https://stackoverflow.com/questions/50220456/spring-data-how-works-pageable-together-with-query-interface-projection