通过嵌套路径使用querydsl的Spring数据休息顺序

时间:2017-05-12 00:59:57

标签: spring-data-jpa spring-data-rest 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> {}

更新 paging-and-sorting.adoc

  

按可链接关联排序(即资源到顶级   资源)不受支持。

但是我看到这是固定的here

更新已添加3.0.0.M2,其中报告问题已修复但仍然无法正常工作

  

版本3.0.0.M2(2017-04-04)的更改

     
      
  • DATAREST-976 - 按嵌入属性排序不再适用于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>

1 个答案:

答案 0 :(得分:0)

降级 spring.data.‌​rest.webmvcHopper发布

<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 (_)

感谢enter image description here@Alan Hay

的评论
  

在Hopper版本中,嵌套属性的排序对我来说很好,但我确实在Ingalls版本的RC版本的RC版本的Ingalls release.bug中遇到了以下错误。据报道这是固定的,

顺便说一句,我试过jira issue - Sorting by an embedded property no longer works in Ingalls RC1报告已修复但未与我合作。