|
|
|
@ -416,6 +416,18 @@ class StringBasedJdbcQueryUnitTests { |
|
|
|
assertThat(paramSource.getValue().getValue("__$synthetic$__2")).isEqualTo("test-value2"); |
|
|
|
assertThat(paramSource.getValue().getValue("__$synthetic$__2")).isEqualTo("test-value2"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // GH-2188
|
|
|
|
|
|
|
|
void shouldPreserveJdbcTypeOtherFromJdbcValueInStringBasedQuery() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SqlParameterSource parameterSource = forMethod("findByCustomValue", Direction.class) |
|
|
|
|
|
|
|
.withCustomConverters(DirectionToOtherJdbcTypeConverter.INSTANCE) |
|
|
|
|
|
|
|
.withArguments(Direction.LEFT) |
|
|
|
|
|
|
|
.extractParameterSource(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(parameterSource.getSqlType("value")) |
|
|
|
|
|
|
|
.isEqualTo(JDBCType.OTHER.getVendorTypeNumber()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QueryFixture forMethod(String name, Class... paramTypes) { |
|
|
|
QueryFixture forMethod(String name, Class... paramTypes) { |
|
|
|
return new QueryFixture(createMethod(name, paramTypes)); |
|
|
|
return new QueryFixture(createMethod(name, paramTypes)); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -562,6 +574,9 @@ class StringBasedJdbcQueryUnitTests { |
|
|
|
@Lock(value = LockMode.PESSIMISTIC_READ) |
|
|
|
@Lock(value = LockMode.PESSIMISTIC_READ) |
|
|
|
@Query("SELECT * FROM person WHERE id = :id") |
|
|
|
@Query("SELECT * FROM person WHERE id = :id") |
|
|
|
DummyEntity unsupportedWithLock(Long id); |
|
|
|
DummyEntity unsupportedWithLock(Long id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Query(value = "some sql statement") // GH-2188
|
|
|
|
|
|
|
|
List<DummyEntity> findByCustomValue(@Param("value") Direction value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class CustomRowMapper implements RowMapper<Object> { |
|
|
|
private static class CustomRowMapper implements RowMapper<Object> { |
|
|
|
@ -655,6 +670,17 @@ class StringBasedJdbcQueryUnitTests { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@WritingConverter // GH-2188
|
|
|
|
|
|
|
|
enum DirectionToOtherJdbcTypeConverter implements Converter<Direction, JdbcValue> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSTANCE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public JdbcValue convert(Direction source) { |
|
|
|
|
|
|
|
return JdbcValue.of(source.name(), JDBCType.OTHER); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class DummyEntity { |
|
|
|
private static class DummyEntity { |
|
|
|
private final Long id; |
|
|
|
private final Long id; |
|
|
|
|
|
|
|
|
|
|
|
|