Support direct DTO mapping for repository query methods
See original GitHub issueHi,
I am writing a custom query but as I am not able to cast the expression to some custom objects. In JPA you can do write custom queries like
@Query("SELECT new com.baeldung.aggregation.model.custom.CommentCount(c.year, COUNT(c.year)) "
+ "FROM Comment AS c GROUP BY c.year ORDER BY c.year DESC")
List<CommentCount> countTotalCommentsByYearClass();
But with ReactiveCassandraRepository I am getting errors org.springframework.data.cassandra.CassandraQuerySyntaxException:
How can I cast to custom object in ReactiveCassandraRepository?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Spring Data JPA - How to Return DTOs from Native Queries
Spring Data JPA doesn't provide an automatic mapping of class-based DTOs for native queries. The easiest way to use this projection is to...
Read more >How to map sql native query result into DTO in spring jpa ...
You can define the following named native query with appropriate sql result set mapping: import javax.persistence.
Read more >Spring Data JPA – How to Return DTOs from Native Queries
When using Spring Data JPA, you are used to derived and custom queries that return the result in your preferred format.
Read more >How to map Custom Query Results into DTO in Spring Data JPA
Introduction In this tutorial I will show you how to map custom query results into DTO in Spring Data JPA. Situations may occur...
Read more >The best way to map a projection query to a DTO (Data ...
Learn the best way to map a DTO projection when using JPA and Hibernate using constructor expression, Tuple, SqlResultSetMapping, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We currently do not have the means to map results through query methods onto DTO’s directly as we always need to consider the underlying entity in terms of column and type mapping. That is a general issue we have with all Spring Data modules and we plan to do something about it in general. For the time being, please use the
CassandraTemplate
directly to run aggregation queries without intermediate entity mapping.as soon as I add maxSalary and minSalary in my Users class, it is working fine. is any better way of doing this??