[x] You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
[x] You submit test cases (unit or integration tests) that back your changes.
[x] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
Closes #1641 Related tickets #1386 #1343
I delete those code and execute sort 4 patterns.
https://github.com/spring-projects/spring-data-rest/blob/f0e86b9a176bbaf43fbc3fba62e935c691e35222/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/JacksonMappingAwareSortTranslator.java#L195-L197
Currently, it seems to support linkable associations. Therefore, I have removed the check process for linkable associations.
Are there any other patterns that should be tested further?
Patterns result:
eager and exported
Path: `/accounts_eager_and_exported?sort=accountType.typeName,desc` Query: ``` Hibernate: select a1_0.id,a1_0.account_type_id,a1_0.name from account a1_0 left join account_type a2_0 on a2_0.id=a1_0.account_type_id order by a2_0.type_name desc offset ? rows fetch first ? rows only ```Entity: AccountEagerAndExported.java
```java package dev.mikoto2000.study.springboot.data.rest.example.entity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.Data; import org.springframework.data.rest.core.annotation.RestResource; @Data @Entity @Table(name = "account") public class AccountEagerAndExported { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @RestResource(exported = true) @JoinColumn(name = "account_type_id") @ManyToOne(fetch = FetchType.EAGER) private AccountType accountType; } ```Repository: AccountEagerAndExportedRepository.java
```java package dev.mikoto2000.study.springboot.data.rest.example.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import dev.mikoto2000.study.springboot.data.rest.example.entity.AccountEagerAndExported; @RepositoryRestResource(collectionResourceRel = "accounts_eager_and_exported", path = "accounts_eager_and_exported") public interface AccountEagerAndExportedRepository extends JpaRepositoryeager and no exported
Path: `/accounts_eager_and_no_exported?sort=accountType.typeName,desc` Query: ```sql Hibernate: select a1_0.id,a1_0.account_type_id,a1_0.name from account a1_0 left join account_type a2_0 on a2_0.id=a1_0.account_type_id order by a2_0.type_name desc offset ? rows fetch first ? rows only ```Entity: AccountEagerAndNoExported.java
```java package dev.mikoto2000.study.springboot.data.rest.example.entity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.Data; import org.springframework.data.rest.core.annotation.RestResource; @Data @Entity @Table(name = "account") public class AccountEagerAndNoExported { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @RestResource(exported = false) @JoinColumn(name = "account_type_id") @ManyToOne(fetch = FetchType.EAGER) private AccountType accountType; } ```Repository: AccountEagerAndNoExportedRepository.java
```java package dev.mikoto2000.study.springboot.data.rest.example.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import dev.mikoto2000.study.springboot.data.rest.example.entity.AccountEagerAndNoExported; @RepositoryRestResource(collectionResourceRel = "accounts_eager_and_no_exported", path = "accounts_eager_and_no_exported") public interface AccountEagerAndNoExportedRepository extends JpaRepositorylazy and exported
Path: `accounts_lazy_and_exported?sort=accountType.typeName,desc` Query: ``` Hibernate: select a1_0.id,a1_0.account_type_id,a1_0.name from account a1_0 left join account_type a2_0 on a2_0.id=a1_0.account_type_id order by a2_0.type_name desc offset ? rows fetch first ? rows only ```Entity: AccountLazyAndExported.java
```java package dev.mikoto2000.study.springboot.data.rest.example.entity; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.Data; import org.springframework.data.rest.core.annotation.RestResource; @Data @Entity @Table(name = "account") public class AccountLazyAndExported { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String name; @RestResource(exported = true) @JoinColumn(name = "account_type_id") @ManyToOne(fetch = FetchType.LAZY) private AccountType accountType; } ```Repository: AccountLazyAndExportedRepository.java
```java package dev.mikoto2000.study.springboot.data.rest.example.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import dev.mikoto2000.study.springboot.data.rest.example.entity.AccountLazyAndExported; @RepositoryRestResource(collectionResourceRel = "accounts_lazy_and_exported", path = "accounts_lazy_and_exported") public interface AccountLazyAndExportedRepository extends JpaRepositorylazy and no exported
In the first place, it is not supported by Spring Data REST.Example code repository: https://github.com/mikoto2000/spring-data-rest-example