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

io.castled.jdbi.JsonMapArgumentFactory 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 JsonMapArgumentFactory extends AbstractArgumentFactory> {

    protected JsonMapArgumentFactory() {
        super(Types.VARCHAR);
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy