1. Entity์์ sorting์ฉ ํ๋ ์ถ๊ฐ ํ, @Formula ์ด๋ ธํ ์ด์ ์ด์ฉ
@Getter
@Setter
@Entity
@Table(name="TABLE")
public class Entity {
...
@Formula("FIELD(STATUS_NAME, '์ง์ฐ', '๊ณํ', '์๋ฃ')")
private String sortingStatus;
}
2. find ์, ์ ๋ ฌ ๊ฐ ์ ํ
List<Entity> productInfo = testRepo.findAll(Sort.by(Sort.Direction.ASC, "sortingStatus"));
'๐ Web > Spring, JPA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SpringBoot] SpringBoot์ Swagger(SpringDoc) ์ ์ฉ (0) | 2023.07.13 |
---|---|
[JPA] error: Attempt to recreate a file for type ~ ... (0) | 2023.07.11 |
[Spring] ๊ฐ์ฒด์ ๊ฐ์ด null์ธ ํ๋ ๋ ธ์ถํ์ง ์๋ ๋ฒ (0) | 2023.05.18 |
[JPA] @Embeddable๋ฅผ ์ด์ฉํ ๋ณตํฉํค ์ค์ (0) | 2023.03.03 |
[Spring] String Constant Pool (0) | 2022.08.02 |