Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,9 @@ private List<OrderByField> extractOrderByFields(Sort sort) {

private OrderByField orderToOrderByField(Sort.Order order) {

SqlIdentifier columnName = this.entity.getRequiredPersistentProperty(order.getProperty()).getColumnName();
Column column = Column.create(columnName, this.getTable());
PersistentPropertyPath<RelationalPersistentProperty> path = mappingContext.getPersistentPropertyPath(order.getProperty(), this.entity.getType());
PersistentPropertyPathExtension extPath = new PersistentPropertyPathExtension(mappingContext, path);
Column column = this.getColumn(extPath);
return OrderByField.from(column, order.getDirection());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ public void findAllSortedBySingleField() {
"ORDER BY x_name ASC");
}

@Test // DATAJDBC-101
@Test // DATAJDBC-101, DATAJDBC-584
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have a separate test case for this. It makes it easier to understand what is going wrong in case of a test failure.

public void findAllSortedByMultipleFields() {

String sql = sqlGenerator.getFindAll(
Sort.by(new Sort.Order(Sort.Direction.DESC, "name"), new Sort.Order(Sort.Direction.ASC, "other")));
Sort.by(new Sort.Order(Sort.Direction.DESC, "name"), new Sort.Order(Sort.Direction.ASC, "ref.content"), new Sort.Order(Sort.Direction.DESC, "ref.further.something")));

assertThat(sql).contains("SELECT", //
"dummy_entity.id1 AS id1", //
Expand All @@ -238,7 +238,8 @@ public void findAllSortedByMultipleFields() {
"LEFT OUTER JOIN referenced_entity ref ON ref.dummy_entity = dummy_entity.id1", //
"LEFT OUTER JOIN second_level_referenced_entity ref_further ON ref_further.referenced_entity = ref.x_l1id", //
"ORDER BY x_name DESC", //
"x_other ASC");
"ref_x_content ASC", //
"ref_further_x_something DESC" );
}

@Test // DATAJDBC-101
Expand Down