All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.castled.jdbi.MapToStringArgumentFactory Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package io.castled.jdbi;

import io.castled.utils.JsonUtils;
import org.jdbi.v3.core.argument.AbstractArgumentFactory;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.config.ConfigRegistry;

import java.sql.Types;
import java.util.Map;

public class MapToStringArgumentFactory extends AbstractArgumentFactory> {

    public MapToStringArgumentFactory() {
        super(Types.VARCHAR);
    }

    @Override
    protected Argument build(Map value, ConfigRegistry config) {
        return (position, statement, ctx) -> statement.setString(position, JsonUtils.objectToString(config));

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy