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

ninja.cero.sqltemplate.core.parameter.ArrayParameter Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package ninja.cero.sqltemplate.core.parameter;

import ninja.cero.sqltemplate.core.util.Jsr310JdbcUtils;
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.ZoneId;

/**
 * {@inheritDoc}
 * Supports {@link java.time.LocalDateTime} and {@link java.time.LocalDate} of JSR-310
 */
public class ArrayParameter extends ArgumentPreparedStatementSetter {
    /** ZoneId for OffsetDateTime and ZonedDateTime */
    protected ZoneId zoneId;

    /**
     * Create a new ArgPreparedStatementSetter for the given arguments.
     *
     * @param args   the arguments to set
     * @param zoneId zoneId
     */
    public ArrayParameter(Object[] args, ZoneId zoneId) {
        super(args);
        this.zoneId = zoneId;
    }

    /**
     * {@inheritDoc}
     */
    protected void doSetValue(PreparedStatement ps, int parameterPosition, Object argValue) throws SQLException {
        super.doSetValue(ps, parameterPosition, Jsr310JdbcUtils.convertIfNecessary(argValue, zoneId));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy