-
Couldn't load subscription status.
- Fork 377
Closed
Labels
status: ideal-for-contributionAn issue that a contributor can help us withAn issue that a contributor can help us withtype: enhancementA general enhancementA general enhancement
Description
Hi guys!
I'm trying to apply sorting in a Pageable, but there is no way to make it work for a property which is part of an @Embedded object.
Entities:
data class Account( @Id val id: Long?, @Embedded.Nullable(prefix = "contact_") val contact: Contact?, )data class Contact( val name: String, )Sort:
Sort.by("contact.name").ascending()Exception:
java.lang.IllegalStateException: Required property contact.name not found for class lms.model.Account! at org.springframework.data.mapping.PersistentEntity.getRequiredPersistentProperty(PersistentEntity.java:161) ~[spring-data-commons-2.6.0.jar:2.6.0] If the PersistentEntity.getRequiredPersistentProperty method doesn't know anything about the @Embedded annotation, I think the following method won't work and it could be the cause of the issue.
Lines 718 to 723 in a684097
| private OrderByField orderToOrderByField(Sort.Order order) { | |
| SqlIdentifier columnName = this.entity.getRequiredPersistentProperty(order.getProperty()).getColumnName(); | |
| Column column = Column.create(columnName, this.getTable()); | |
| return OrderByField.from(column, order.getDirection()).withNullHandling(order.getNullHandling()); | |
| } |
Should you use the
SqlGenerator.getTable().column() method instead?Metadata
Metadata
Assignees
Labels
status: ideal-for-contributionAn issue that a contributor can help us withAn issue that a contributor can help us withtype: enhancementA general enhancementA general enhancement