검색결과 리스트
글
LANGUAGE/SPRING
2017. 3. 27. 11:49
MyBatis (마이바티스)
MyBatis를 사용하다보면, "여기서 그 자바 함수를 사용하면 딱인데"
라고 생각이 드는 순간이 있다.
다행히도 static으로 선언된 함수(method)
를 사용할 수 있게 할 수 있다.
static 함수사용하기
static 함수가 있는 Class의 classpath
를 @
이와 함께 적고, 사용할 함수명
을 적는다.
예)
@foo.Bar@myMethod()
- IF문에서 사용예
<if test="@com.myproject.Util@isNice(#{parameter})">
AND SONG_CODE = #{songCode}
</if>
- Parameter로 사용예
<insert id="insertFooBar">
INSERT INTO FOO_TABLE(
BAR_COL
)VALUE(
${@foo.Bar@myMethod()}
)
</insert>
참고
Calling a java static method as parameter in MyBatis 3.1 SQL Query: http://mybatis-user.963551.n3.nabble.com/Calling-a-java-static-method-as-parameter-in-MyBatis-3-1-SQL-Query-td4028393.html
'LANGUAGE > SPRING' 카테고리의 다른 글
[간단정리] 갑자기 Spring4 소스를 분석해야 하는 친구를 위한 (0) | 2020.03.11 |
---|---|
[잡담] 스프링! 한글과 비견될 수 있을까? .. (0) | 2020.03.09 |
[SpringBoot] logging (0) | 2016.05.11 |
[Spring] SessionStatus (0) | 2016.03.09 |
[Spring Boot] log (0) | 2016.02.24 |