I want to order
using Nested Path
Not working
curl -i -X GET http://localhost:8080/api/appointment?sort=doctor.name,{desc|asc} // Not working
While this working
curl -i -X GET http://localhost:8080/api/appointment?sort=appointmentDay,{desc/asc} // working
curl -i -X GET http://localhost:8080/api/appointment?dcotor.name=Ahmed // working
Entity
public class Appointment implements Serializable {
@Column(name = "appointment_day")
@Future(message = "Day of appointment must be in the future!")
@NotNull
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
@JsonFormat(pattern = Constants.DATE_PATTEN)
@DateTimeFormat(iso = ISO.DATE)
private Date appointmentDay;
@ManyToOne(optional = false)
@JoinColumn(name = "doctor_id", nullable = false)
private Doctor doctor;
// Other properties
//
}
Repository
@RepositoryRestResource(path = "appointment", collectionResourceRel = "data", excerptProjection = AppointmentExcerpt.class)
public interface AppointmentRepo extends JpaRepository<Appointment, Long>,
QueryDslPredicateExecutor<Appointment>, QuerydslBinderCustomizer<QAppointment> {}
Update paging-and-sorting.adoc
Sorting by linkable associations (i.e. resources to top-level resources) is not supported.
But i see that was fixed here
Update Added 3.0.0.M2 which reported that issue fixed, But still Not working
Changes in version 3.0.0.M2 (2017-04-04)
- DATAREST-976 - Sorting by an embedded property no longer works in Ingalls RC1.
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>rabbit-milestones</id>
<name>Rabbit Milestones</name>
<url>https://dl.bintray.com/rabbitmq/maven-milestones</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.0.M3</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>3.0.0.M3</version>
</dependency>
Just downgraded spring.data.rest.webmvc
to Hopper
release
<spring.data.jpa.version>1.10.10.RELEASE</spring.data.jpa.version>
<spring.data.rest.webmvc.version>2.5.10.RELEASE</spring.data.rest.webmvc.version>
/api/appointment?sort=doctor.name,{desc|asc} // works with (.)
/api/appointment?sort=doctor_name,{desc|asc} // works too with (_)
Thanks @Alan Hay comment on this question
Ordering by nested properties works fine for me in the Hopper release but I did experience the following bug in an RC version of the Ingalls release.bug in an RC version of the Ingalls release. This is reported as being fixed,
BTW, I tried v3.0.0.M3
that reported that fixed but not working with me.