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

run.smt.ktest.db.query.impl.SelectBuilder.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package run.smt.ktest.db.query.impl

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate

/**
 * Represents SELECT query
 */
class SelectBuilder(_query: String? = null) : RespondingQueryImpl(_query) { init {

    singleLoader { jdbcTemplate ->
        val jdbc = NamedParameterJdbcTemplate(jdbcTemplate)
        if (forPrimitive) {
            jdbc.queryForObject(query, parameterImplementation(), mapTo.java)
        } else {
            jdbc.queryForObject(query, parameterImplementation(), SimpleRowMapper(mapTo))
        }
    }

    listLoader { jdbcTemplate ->
        val jdbc = NamedParameterJdbcTemplate(jdbcTemplate)
        if (forPrimitive) {
            jdbc.queryForList(query, parameterImplementation(), mapTo.java)
        } else {
            jdbc.query(query, parameterImplementation(), SimpleRowMapper(mapTo))
        }
    }

    mapLoader { jdbcTemplate ->
        NamedParameterJdbcTemplate(jdbcTemplate).queryForMap(query, parameterImplementation())
    }
} }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy