ConvertibleBeanPropertySqlParameterSource 에서 parameterName 에 prefix 설정 지원
mhyeon-lee opened this issue · 1 comments
mhyeon-lee commented
- ConvertibleBeanPropertySqlParameterSource 에서 parameterName 에 prefix 를 지정할 수 있는 기능을 추가한다.
- "test." 이라는 prefix 를 담은 ConvertibleBeanPropertySqlParameterSource 객체에 다음의 클래스 객체를 넣었을 때, ":test.value1", ":test.value2" 로 각 변수의 값을 얻을 수 있다.
public class Test {
private String value1;
private int value2;
public String getValue1() {
return this.value1;
}
public int getValue2() {
return this.value2;
}
}
mhyeon-lee commented
@Test
void getPrefixValue() {
// given
String paramName = "occurrenceTime";
Criteria criteria = Criteria.of("sample", Instant.now());
ConvertibleBeanPropertySqlParameterSource sut = new ConvertibleBeanPropertySqlParameterSource(
"test.", criteria, this.converter);
// when
Object actual = sut.getValue("test.occurrenceTime");
// then
assertThat(actual).isNotNull();
}
static class Criteria {
private String name;
private Instant occurrenceTime;
static Criteria of(String name, Instant occurrenceTime) {
Criteria criteria = new Criteria();
criteria.name = name;
criteria.occurrenceTime = occurrenceTime;
return criteria;
}
public String getName() {
return this.name;
}
public Instant getOccurrenceTime() {
return this.occurrenceTime;
}
}