[hibernate 6] custom 함수 등록 방법 공유
3503
작성한 질문수 2
Hibernate 6에서는 강의에서 처럼 Dialect를 통한 함수 등록이 불가능합니다.
https://start.spring.io/로 Spring Boot 3버전으로 만드신 분들은 문제를 겪으실 거라고 생각합니다.
등록법
FunctionContributer의 구현체를 만들어 준다.
package custom;
import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.boot.model.FunctionContributor;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.StandardBasicTypes;
public class CustomFunctionContributor implements FunctionContributor {
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
functionContributions.getFunctionRegistry()
.register("group_concat", new StandardSQLFunction("group_concat", StandardBasicTypes.STRING));
}
}
src/main/resources/META-INF/services/org.hibernate.boot.model.FunctionContributor파일을 생성한다.해당 파일에 직접 구현한 CustomFunctionContributor를 등록한다.
패키지명.컨트리뷰터이름 형태로 등록!!
custom.CustomFunctionContributor


이렇게 하시면, 강의에서처럼 group_concat함수를 사용하실 수 있습니다.
Dialect는 변경 안하셔도 됩니다.
reference
https://aregall.tech/hibernate-6-custom-functions
답변 5
벌크연산에서 member.getAge 호출 시 영속성 컨텍스트에서 데이터를 가져오는건가요?
0
27
2
inheritance startegy 선택시 고려사항
0
22
1
Entity 동등성 비교
0
21
1
실무 조언 관련 질문입니다.
0
46
1
H2데이터베이스 파일 생성
0
56
2
서브쿼리 강의에서 ALL 예시 관련 질문드립니다.
0
52
2
수정또는 삭제시 영속성 엔티티에 값이 무조건 있어야 하나요?
0
52
1
JPQL 메소드와 락
0
55
1
Delivery @OneToOne
0
60
1
17강 4~5분대 테이블 값 조회가 안됩니다.
0
93
2
UnsupportedOperationException 발생
0
86
3
H2 Database 연결이 안됩니다.
0
93
2
연관관계 매핑 질문드립니다.
0
85
2
h2데이터베이스 실행오류
0
107
2
persistence.xml
0
106
2
양방향 연관관계에서 연관관계의 주인(mappedBy)을 왜 꼭 정해야 하나요?
0
80
1
영속성 컨텍스트
0
66
1
JPA 프록시
0
96
1
Native Query와 MyBatis
0
70
1
영속성 컨텍스트는 어떤 메모리에 저장되는건가요?
0
87
1
임베디드 타입 예시 코드 관련 질문
0
114
3
명시적 조인에서 별칭을 주면 왜 객체에 접근할 수 있나요
0
94
3
인텔리제이 패키지 커서 단축키 질문
0
108
2
혹시 현재는 ID 데이터 타입이 String이면 안되나요?
0
145
1





