Spring 使用 querydsl 的嵌套路径的数据休息顺序
Spring data rest order by nested path with querydsl
我想 order
使用 Nested Path
不工作
curl -i -X GET http://localhost:8080/api/appointment?sort=doctor.name,{desc|asc} // Not 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
实体
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
//
}
存储库
@RepositoryRestResource(path = "appointment", collectionResourceRel = "data", excerptProjection = AppointmentExcerpt.class)
public interface AppointmentRepo extends JpaRepository<Appointment, Long>,
QueryDslPredicateExecutor<Appointment>, QuerydslBinderCustomizer<QAppointment> {}
Sorting by linkable associations (i.e. resources to top-level
resources) is not supported.
但是我看到那是固定的here
更新 添加了 3.0.0.M2 报告该问题已解决,但仍然 无法正常工作
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>
刚刚 降级 spring.data.rest.webmvc
到 Hopper
发布
<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 (_)
谢谢@Alan Hay comment on
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,
顺便说一句,我试过 v3.0.0.M3
报告已修复但无法与我一起使用。
我想 order
使用 Nested Path
不工作
curl -i -X GET http://localhost:8080/api/appointment?sort=doctor.name,{desc|asc} // Not 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
实体
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
//
}
存储库
@RepositoryRestResource(path = "appointment", collectionResourceRel = "data", excerptProjection = AppointmentExcerpt.class)
public interface AppointmentRepo extends JpaRepository<Appointment, Long>,
QueryDslPredicateExecutor<Appointment>, QuerydslBinderCustomizer<QAppointment> {}
Sorting by linkable associations (i.e. resources to top-level resources) is not supported.
但是我看到那是固定的here
更新 添加了 3.0.0.M2 报告该问题已解决,但仍然 无法正常工作
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>
刚刚 降级 spring.data.rest.webmvc
到 Hopper
发布
<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 (_)
谢谢@Alan Hay comment on
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,
顺便说一句,我试过 v3.0.0.M3
报告已修复但无法与我一起使用。