Spring boot @Formula사용해서 Count Query 하기
@Formula Spring boot Hibernate @Formula 사용하여 Count 하기 프로젝트를 진행할 떄 게시판을 만든다는 가정을 한다. 게시글 댓글이 1:N의 관계이다. 만약 게시글을 불러오면서 댓글의 총 갯수를 알고 싶을때 @Formula 어노테이션을 유용하게 사용 할 수 있을 듯하다. Entity 수정 @Entity public class Board { private Long id; private String title; private String contents; @Formual("(select count(1) from board_comment bc where bc.board_id = id)") private int totalCommentCount; } @Formula 어노테이션을 붙..
Dev/Spring
2020. 7. 12. 15:53
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 스프링시큐리티
- 스프링부트 시작하기
- API
- Java
- ResourceHttpReqeustHandler
- ControllerAdvice
- Security
- boot
- springsecurity
- 자바
- 스프링부트
- Python
- springboot
- paawordencoder
- FastAPI
- like절
- 개발
- Spring
- JPA
- spring web
- mapstruct
- ubuntu
- 유사결과
- java11
- 웹서비스
- @formula
- QueryDSL
- 스프링
- booleanExpression
- howtoinstallnginx
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
글 보관함