зеркало из
https://github.com/iharh/notes.git
synced 2025-11-03 07:06:09 +02:00
m
Этот коммит содержится в:
родитель
2bc354a13f
Коммит
7f2a958d4d
1
db/sql/postgres/feature/type/enum.txt
Обычный файл
1
db/sql/postgres/feature/type/enum.txt
Обычный файл
@ -0,0 +1 @@
|
|||||||
|
https://www.postgresql.org/docs/current/datatype-enum.html
|
||||||
5
pl/java/libfws/spring/data/jdbc/features/jsonb-support.txt
Обычный файл
5
pl/java/libfws/spring/data/jdbc/features/jsonb-support.txt
Обычный файл
@ -0,0 +1,5 @@
|
|||||||
|
https://stackoverflow.com/questions/64521056/how-to-read-write-postgres-jsonb-type-with-spring-data-jdbc
|
||||||
|
|
||||||
|
2024
|
||||||
|
https://habr.com/ru/companies/T1Holding/articles/858762/
|
||||||
|
overriding AbstractJdbcConfiguration.userConverters is the thing!
|
||||||
143
pl/java/libfws/spring/data/jdbc/features/query-params-jdbc-types.txt
Обычный файл
143
pl/java/libfws/spring/data/jdbc/features/query-params-jdbc-types.txt
Обычный файл
@ -0,0 +1,143 @@
|
|||||||
|
ERROR: operator does not exist: = character varying Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
|
||||||
|
|
||||||
|
https://github.com/spring-projects/spring-data-relational/issues/1136
|
||||||
|
https://github.com/spring-projects/spring-data-relational/pull/1517
|
||||||
|
|
||||||
|
JdbcTemplate
|
||||||
|
query -> prepareStatement(query, params)
|
||||||
|
|
||||||
|
protected PreparedStatement prepareStatement(String sql, Object[] params)
|
||||||
|
|
||||||
|
org.springframework.data.jdbc.repository.query
|
||||||
|
PartThreeJdbcQuery
|
||||||
|
|
||||||
|
public Object execute(Object[] values) {
|
||||||
|
RelationalParametersParameterAccessor accessor = new RelationalParametersParameterAccessor(this.getQueryMethod(), values);
|
||||||
|
ResultProcessor processor = this.getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
|
||||||
|
ParametrizedQuery query = this.createQuery(accessor, processor.getReturnedType()); // !!!
|
||||||
|
JdbcQueryExecution<?> execution = this.getQueryExecution(processor, accessor);
|
||||||
|
return execution.execute(query.getQuery(), query.getParameterSource(this.dialect.getLikeEscaper()));
|
||||||
|
}
|
||||||
|
|
||||||
|
JdbcQueryMethod : QueryMethod
|
||||||
|
parameter
|
||||||
|
|
||||||
|
QueryMethod.QueryMethod
|
||||||
|
...
|
||||||
|
this.parameters = this.createParameters(method, metadata.getDomainTypeInformation());
|
||||||
|
...
|
||||||
|
|
||||||
|
package org.springframework.data.repository.query;
|
||||||
|
public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter> implements Streamable<T> {
|
||||||
|
...
|
||||||
|
protected Parameters(ParametersSource parametersSource, Function<MethodParameter, T> parameterFactory) {
|
||||||
|
Assert.notNull(parametersSource, "ParametersSource must not be null");
|
||||||
|
Assert.notNull(parameterFactory, "Parameter factory must not be null");
|
||||||
|
Method method = parametersSource.getMethod();
|
||||||
|
int parameterCount = method.getParameterCount();
|
||||||
|
this.parameters = new ArrayList(parameterCount);
|
||||||
|
this.dynamicProjectionIndex = -1;
|
||||||
|
int scrollPositionIndex = -1;
|
||||||
|
int pageableIndex = -1;
|
||||||
|
int sortIndex = -1;
|
||||||
|
int limitIndex = -1;
|
||||||
|
|
||||||
|
for(int i = 0; i < parameterCount; ++i) {
|
||||||
|
MethodParameter methodParameter = (new MethodParameter(method, i)).withContainingClass(parametersSource.getContainingClass());
|
||||||
|
methodParameter.initParameterNameDiscovery(PARAMETER_NAME_DISCOVERER);
|
||||||
|
T parameter = (T)(parameterFactory.apply(methodParameter));
|
||||||
|
if (parameter.isSpecialParameter() && parameter.isNamedParameter()) {
|
||||||
|
throw new IllegalArgumentException(PARAM_ON_SPECIAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameter.isDynamicProjectionParameter()) {
|
||||||
|
this.dynamicProjectionIndex = parameter.getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ScrollPosition.class.isAssignableFrom(parameter.getType())) {
|
||||||
|
scrollPositionIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pageable.class.isAssignableFrom(parameter.getType())) {
|
||||||
|
pageableIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Sort.class.isAssignableFrom(parameter.getType())) {
|
||||||
|
sortIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Limit.class.isAssignableFrom(parameter.getType())) {
|
||||||
|
limitIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.parameters.add(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scrollPositionIndex = scrollPositionIndex;
|
||||||
|
this.pageableIndex = pageableIndex;
|
||||||
|
this.sortIndex = sortIndex;
|
||||||
|
this.limitIndex = limitIndex;
|
||||||
|
this.bindable = Lazy.of(this::getBindable);
|
||||||
|
this.assertEitherAllParamAnnotatedOrNone();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ParametersSource of(final RepositoryMetadata metadata, final Method method) {
|
||||||
|
..
|
||||||
|
return new ParametersSource() {
|
||||||
|
...
|
||||||
|
public TypeInformation<?> getDomainTypeInformation() {
|
||||||
|
return metadata.getDomainTypeInformation(); // entity.Order
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JdbcParameters extends RelationalParameters {
|
||||||
|
...
|
||||||
|
public static class JdbcParameter extends RelationalParameters.RelationalParameter {
|
||||||
|
private final SQLType sqlType;
|
||||||
|
private final Lazy<SQLType> actualSqlType;
|
||||||
|
|
||||||
|
JdbcParameter(MethodParameter parameter, TypeInformation<?> domainType) {
|
||||||
|
super(parameter, domainType);
|
||||||
|
TypeInformation<?> typeInformation = this.getTypeInformation();
|
||||||
|
this.sqlType = JdbcUtil.targetSqlTypeFor(
|
||||||
|
JdbcColumnTypes.INSTANCE.resolvePrimitiveType(typeInformation.getType())
|
||||||
|
); //
|
||||||
|
this.actualSqlType = Lazy.of(() -> JdbcUtil.targetSqlTypeFor(JdbcColumnTypes.INSTANCE.resolvePrimitiveType(typeInformation.getActualType().getType())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
org.springframework.data.jdbc.support
|
||||||
|
JdbcUtil
|
||||||
|
public static SQLType targetSqlTypeFor(Class<?> type) {
|
||||||
|
Assert.notNull(type, "Type must not be null");
|
||||||
|
Optional var10000 = sqlTypeMappings.keySet().stream().filter((k) -> k.isAssignableFrom(type)).findFirst();
|
||||||
|
Map var10001 = sqlTypeMappings;
|
||||||
|
Objects.requireNonNull(var10001);
|
||||||
|
return (SQLType)var10000.map(var10001::get).orElse(TYPE_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
org.springframework.data.jdbc.core.convert
|
||||||
|
public enum JdbcColumnTypes {
|
||||||
|
INSTANCE {
|
||||||
|
public Class<?> resolvePrimitiveType(Class<?> type) {
|
||||||
|
return (Class)JdbcColumnTypes.javaToDbType.entrySet().stream().filter((e) -> ((Class)e.getKey()).isAssignableFrom(type)).map((e) -> (Class)e.getValue()).findFirst().orElseGet(() -> ClassUtils.resolvePrimitiveIfNecessary(type));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final Map<Class<?>, Class<?>> javaToDbType = new LinkedHashMap();
|
||||||
|
|
||||||
|
private JdbcColumnTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Class<?> resolvePrimitiveType(Class<?> type);
|
||||||
|
|
||||||
|
static {
|
||||||
|
javaToDbType.put(Enum.class, String.class); // !!!
|
||||||
|
javaToDbType.put(ZonedDateTime.class, String.class);
|
||||||
|
javaToDbType.put(OffsetDateTime.class, OffsetDateTime.class);
|
||||||
|
javaToDbType.put(LocalDateTime.class, LocalDateTime.class);
|
||||||
|
javaToDbType.put(Temporal.class, Timestamp.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
pl/java/libfws/spring/data/logging.txt
Обычный файл
5
pl/java/libfws/spring/data/logging.txt
Обычный файл
@ -0,0 +1,5 @@
|
|||||||
|
pg
|
||||||
|
org.postgresql.core.v3
|
||||||
|
QueryExecutorImpl
|
||||||
|
SimpleQuery
|
||||||
|
FINEST
|
||||||
Загрузка…
x
Ссылка в новой задаче
Block a user