Skip to content

Commit fde380f

Browse files
committed
Introduced the caching of the YdbTypes
1 parent 504cf1a commit fde380f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/YdbMappingJdbcConverter.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package tech.ydb.data.core.convert;
22

33
import java.sql.SQLType;
4+
import java.util.concurrent.ConcurrentHashMap;
5+
import java.util.concurrent.ConcurrentMap;
6+
47
import org.springframework.data.convert.CustomConversions;
58
import org.springframework.data.jdbc.core.convert.JdbcTypeFactory;
69
import org.springframework.data.jdbc.core.convert.MappingJdbcConverter;
@@ -16,13 +19,19 @@
1619
@SuppressWarnings("removal")
1720
public class YdbMappingJdbcConverter extends MappingJdbcConverter {
1821

22+
private final ConcurrentMap<RelationalPersistentProperty, SQLType> typesCache = new ConcurrentHashMap<>();
23+
1924
public YdbMappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver,
2025
CustomConversions conversions, JdbcTypeFactory typeFactory) {
2126
super(context, relationResolver, conversions, typeFactory);
2227
}
2328

2429
@Override
2530
public SQLType getTargetSqlType(RelationalPersistentProperty property) {
31+
return typesCache.computeIfAbsent(property, this::resolveSqlType);
32+
}
33+
34+
private SQLType resolveSqlType(RelationalPersistentProperty property) {
2635
// the new api takes precedence
2736
var ydbType = property.findAnnotation(tech.ydb.data.core.convert.annotation.YdbType.class);
2837

0 commit comments

Comments
 (0)