Search in sources :

Example 1 with PojoProperties

use of org.jdbi.v3.core.mapper.reflect.internal.PojoProperties in project jdbi by jdbi.

the class PojoWarmingCustomizer method of.

public static SqlStatementParameterCustomizer of(Type pojoType, SqlStatementParameterCustomizer customizer) {
    return new SqlStatementParameterCustomizer() {

        @Override
        public void apply(SqlStatement<?> stmt, Object arg) throws SQLException {
            customizer.apply(stmt, arg);
        }

        @Override
        public void warm(ConfigRegistry config) {
            Arguments arguments = config.get(Arguments.class);
            config.get(PojoTypes.class).findFor(pojoType).map(Stream::of).orElseGet(Stream::empty).map(PojoProperties::getProperties).map(Map::values).flatMap(Collection::stream).map(PojoProperty::getQualifiedType).forEach(arguments::prepareFor);
        }
    };
}
Also used : SqlStatement(org.jdbi.v3.core.statement.SqlStatement) ConfigRegistry(org.jdbi.v3.core.config.ConfigRegistry) PojoProperties(org.jdbi.v3.core.mapper.reflect.internal.PojoProperties) Arguments(org.jdbi.v3.core.argument.Arguments) Collection(java.util.Collection) Stream(java.util.stream.Stream) SqlStatementParameterCustomizer(org.jdbi.v3.sqlobject.customizer.SqlStatementParameterCustomizer)

Aggregations

Collection (java.util.Collection)1 Stream (java.util.stream.Stream)1 Arguments (org.jdbi.v3.core.argument.Arguments)1 ConfigRegistry (org.jdbi.v3.core.config.ConfigRegistry)1 PojoProperties (org.jdbi.v3.core.mapper.reflect.internal.PojoProperties)1 SqlStatement (org.jdbi.v3.core.statement.SqlStatement)1 SqlStatementParameterCustomizer (org.jdbi.v3.sqlobject.customizer.SqlStatementParameterCustomizer)1