[hibernate 6] custom 함수 등록 방법 공유
3499
2 asked
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
Answer 5
실무 조언 관련 질문입니다.
0
38
1
H2데이터베이스 파일 생성
0
45
2
서브쿼리 강의에서 ALL 예시 관련 질문드립니다.
0
47
2
수정또는 삭제시 영속성 엔티티에 값이 무조건 있어야 하나요?
0
45
1
JPQL 메소드와 락
0
47
1
Delivery @OneToOne
0
54
1
17강 4~5분대 테이블 값 조회가 안됩니다.
0
85
2
UnsupportedOperationException 발생
0
80
3
H2 Database 연결이 안됩니다.
0
86
2
연관관계 매핑 질문드립니다.
0
77
2
h2데이터베이스 실행오류
0
103
2
persistence.xml
0
101
2
양방향 연관관계에서 연관관계의 주인(mappedBy)을 왜 꼭 정해야 하나요?
0
74
1
영속성 컨텍스트
0
59
1
JPA 프록시
0
86
1
Native Query와 MyBatis
0
61
1
영속성 컨텍스트는 어떤 메모리에 저장되는건가요?
0
81
1
임베디드 타입 예시 코드 관련 질문
0
110
3
명시적 조인에서 별칭을 주면 왜 객체에 접근할 수 있나요
0
89
3
인텔리제이 패키지 커서 단축키 질문
0
100
2
혹시 현재는 ID 데이터 타입이 String이면 안되나요?
0
133
1
양방향 연관관계 시 연관관계 주인을 설정하는 이유
0
67
1
임베디드 타입과 MappedSuperClass의 차이점이 궁금합니다.
0
95
1
데이터베이스가 초기화되는 것 같아요
1
172
2

