spring-data-relational
spring-data-relational copied to clipboard
Spring Data JDBC - Sort.by does not work on nested @Embedded property
Hi,
Similar to this old issue https://github.com/spring-projects/spring-data-relational/issues/1286, I have another use case that doesn't seem to work for a nested @Embedded sort.
To summarize the use case with an example:
@Entity
class MyTable(
@OneToOne
MyTableDetails tableDetails;
.....
)
@Entity
class MyTableDetails(
@Embedded
MoreEmbeddedDEtails moreDetails;
....
)
@Embeddable
class MoreEmbeddedDEtails(
string simpleDetail
)
So when I try to sort on my MyTable, it looks like Sort.by("tableDetails.moreDetails.simpleDetail").ascending(), but I got an error similar to this one:
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [moreDetails.simpleDetail] on this ManagedType [MyTableDetails]
Currently using version spring-data-commons-2.7.18.
Thanks
Are we talking about Spring Data JDBC? Because you use @Embeddable which is not a Spring Data JDBC annotation and @Embedded can not be used without value for oneEmpty. This looks like Spring Data JPA to me.
In either case please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.