Example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate

List of usage examples for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate

Introduction

In this page you can find the example usage for org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate NamedParameterJdbcTemplate.

Prototype

public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate) 

Source Link

Document

Create a new NamedParameterJdbcTemplate for the given classic Spring org.springframework.jdbc.core.JdbcTemplate .

Usage

From source file:com.joliciel.lefff.LefffDaoImpl.java

public Attribute loadAttribute(String attributeCode, String attributeValue) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());

    String sql = "SELECT " + SELECT_ATTRIBUTE + " FROM lef_attribute" + " WHERE attribute_code=:attribute_code"
            + " AND attribute_value=:attribute_value";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("attribute_code", attributeCode);
    paramSource.addValue("attribute_value", attributeValue);

    LOG.info(sql);/*from w  w w.j  ava 2 s .  c  om*/
    LefffDaoImpl.LogParameters(paramSource);
    Attribute attribute = null;
    try {
        attribute = (Attribute) jt.queryForObject(sql, paramSource,
                new AttributeMapper(this.getLefffServiceInternal()));
    } catch (EmptyResultDataAccessException ex) {
        ex.hashCode();
    }
    return attribute;
}

From source file:org.pegadi.server.article.ArticleServerImpl.java

public void setDataSource(DataSource dataSource) {
    template = new NamedParameterJdbcTemplate(dataSource);
}

From source file:com.jd.survey.dao.survey.SurveyDAOImpl.java

@Autowired
public void setBasicDataSource(DataSource basicDataSource) {
    this.jdbcTemplate = new JdbcTemplate(basicDataSource);
    this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(basicDataSource);
}

From source file:org.apereo.services.persondir.support.jdbc.NamedParameterJdbcPersonAttributeDao.java

@Override
public void afterPropertiesSet() throws Exception {
    jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}

From source file:cherry.sqlapp.service.sqltool.exec.ExecQueryServiceImpl.java

private long count(DataSource dataSource, String sql, Map<String, ?> paramMap) {
    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(dataSource);
    return template.queryForObject(sql, paramMap, Long.class);
}

From source file:ch.digitalfondue.npjt.QueryFactory.java

public QueryFactory(String activeDB, DataSource dataSource) {
    this.activeDb = activeDB;
    this.jdbc = new NamedParameterJdbcTemplate(dataSource);
}

From source file:com.joliciel.talismane.terminology.postgres.PostGresTerminologyBase.java

@Override
public List<Term> getTerms(int frequencyThreshold, String searchText, boolean marked,
        boolean markedExpansions) {
    MONITOR.startTask("getTerms");
    try {//w w w .j  av  a2 s  . co  m
        NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
        String sql = "SELECT " + SELECT_TERM + " FROM term" + " INNER JOIN text ON term_text_id=text_id"
                + " WHERE term_project_id = :term_project_id";
        if (marked && markedExpansions) {
            sql += " AND term_marked = :term_marked";
            if (searchText.length() > 0)
                sql += " AND text_text LIKE :term_text";
        } else {
            if (frequencyThreshold > 0)
                sql += " AND term_frequency >= :term_frequency";
            if (searchText.length() > 0)
                sql += " AND text_text LIKE :term_text";
            if (marked)
                sql += " AND term_marked = :term_marked";
        }
        sql += " ORDER BY term_frequency DESC, text_text";
        MapSqlParameterSource paramSource = new MapSqlParameterSource();
        if (frequencyThreshold > 0)
            paramSource.addValue("term_frequency", frequencyThreshold);
        if (searchText.length() > 0)
            paramSource.addValue("term_text", searchText + "%");
        if (marked)
            paramSource.addValue("term_marked", true);
        paramSource.addValue("term_project_id", this.getCurrentProjectId());

        LOG.trace(sql);
        LogParameters(paramSource);
        @SuppressWarnings("unchecked")
        List<Term> terms = jt.query(sql, paramSource, new TermMapper());

        if (marked && markedExpansions) {
            this.addParents(terms);
            List<Term> termsWithFrequency = new ArrayList<Term>();
            for (Term term : terms) {
                int maxAncestorFrequency = this.getMaxAncestorFrequency(term);
                if (maxAncestorFrequency >= frequencyThreshold)
                    termsWithFrequency.add(term);
            }
            terms = termsWithFrequency;
        }

        return terms;
    } finally {
        MONITOR.endTask("getTerms");
    }
}

From source file:edu.wisc.jmeter.dao.JdbcMonitorDao.java

public JdbcMonitorDao(DataSource dataSource, int purgeOldFailures, int purgeOldStatus) {
    this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);

    final DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(
            dataSource);// www .j  av a2s .  c o m
    dataSourceTransactionManager.afterPropertiesSet();

    this.transactionTemplate = new TransactionTemplate(dataSourceTransactionManager);
    this.transactionTemplate.afterPropertiesSet();

    this.purgeOldFailure = TimeUnit.MILLISECONDS.convert(purgeOldFailures, TimeUnit.MINUTES);
    this.purgeOldStatus = TimeUnit.MILLISECONDS.convert(purgeOldStatus, TimeUnit.MINUTES);
}

From source file:ch.digitalfondue.npjt.QueryFactory.java

public QueryFactory(String activeDB, JdbcTemplate jdbcTemplate) {
    this.activeDb = activeDB;
    this.jdbc = new NamedParameterJdbcTemplate(jdbcTemplate);
}

From source file:com.joliciel.jochre.graphics.GraphicsDaoJdbc.java

@Override
public List<Shape> findShapes(GroupOfShapes group) {
    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(this.getDataSource());
    String sql = "SELECT " + SELECT_SHAPE + " FROM ocr_shape WHERE shape_group_id=:shape_group_id"
            + " ORDER BY shape_index";
    MapSqlParameterSource paramSource = new MapSqlParameterSource();
    paramSource.addValue("shape_group_id", group.getId());

    LOG.debug(sql);//ww  w  .  j  a  va  2 s . co m
    logParameters(paramSource);
    @SuppressWarnings("unchecked")
    List<Shape> shapes = jt.query(sql, paramSource, new ShapeMapper(this.getGraphicsServiceInternal()));

    return shapes;
}