Example usage for org.springframework.jdbc.core BeanPropertyRowMapper newInstance

List of usage examples for org.springframework.jdbc.core BeanPropertyRowMapper newInstance

Introduction

In this page you can find the example usage for org.springframework.jdbc.core BeanPropertyRowMapper newInstance.

Prototype

public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass) 

Source Link

Document

Static factory method to create a new BeanPropertyRowMapper (with the mapped class specified only once).

Usage

From source file:sk.upjs.ics.autobazar.MySqlInzeratKaravanDao.java

@Override
public List<InzeratKaravan> vyhladaj(String znacka, String model, String odRocnik, String doRocnik) {
    String sql = "select * from inzeratKaravan where znacka = ? and model = ? and rocnik >= ? and rocnik <= ?";
    BeanPropertyRowMapper<InzeratKaravan> mapper = BeanPropertyRowMapper.newInstance(InzeratKaravan.class);
    return jdbcTemplate.query(sql, mapper, znacka, model, odRocnik, doRocnik);
}

From source file:kniznica.SQLHerec.java

@Override
public List<Herec> dajVsetkychZID(String id) {
    String sql = "SELECT * FROM herec where id = " + id;
    BeanPropertyRowMapper<Herec> mapper = BeanPropertyRowMapper.newInstance(Herec.class);
    return jdbcTemplate.query(sql, mapper);
}

From source file:kniznica.SQLReziser.java

@Override
public Reziser podlaID(int id) {
    String sql = "SELECT * FROM reziser where id = " + id;
    BeanPropertyRowMapper<Reziser> mapper = BeanPropertyRowMapper.newInstance(Reziser.class);
    List<Reziser> reziseri = jdbcTemplate.query(sql, mapper);
    Reziser vysledny = reziseri.get(0);//w w w. ja  va2  s  . c  o  m
    return vysledny;
}

From source file:kniznica.SQLFilm.java

@Override
public Film podlaID(int id) {
    String sql = "SELECT * FROM filmy where id = " + id;
    BeanPropertyRowMapper<Film> mapper = BeanPropertyRowMapper.newInstance(Film.class);
    List<Film> filmy = jdbcTemplate.query(sql, mapper);
    Film vysledny = filmy.get(0);//from  w w w  .  j av  a  2 s .  c om
    return vysledny;
}

From source file:kniznica.SQLScenarista.java

@Override
public Scenarista podlaID(int id) {
    String sql = "SELECT * FROM scenarista where id = " + id;
    BeanPropertyRowMapper<Scenarista> mapper = BeanPropertyRowMapper.newInstance(Scenarista.class);
    List<Scenarista> herci = jdbcTemplate.query(sql, mapper);
    Scenarista vysledny = herci.get(0);/*from w w w.  jav a2 s.  co  m*/
    return vysledny;
}

From source file:com.concur.dao.ArchiveRunDaoImpl.java

@Override
public Collection<ArchiveRun> findArchiveRuns() throws DataAccessException {
    System.out.println("in archive run com.concur.dao impl");

    return this.jdbcTemplate.query("SELECT  etl_batch_key job_key, etl_status job_status, "
            + "DATEDIFF(MINUTE, etl_start_dttm, etl_end_dttm) job_duration " + "FROM dbo.dim_etl_batch "
            + "WHERE job_type = 'DW_GEXP_ARCHIVE' " + "AND etl_status NOT IN ('RUNNING') "
            + "ORDER BY etl_batch_key", BeanPropertyRowMapper.newInstance(ArchiveRun.class));
}

From source file:kniznica.SQLFilm.java

@Override
public List<Film> dajVsetkychZaner(String zaner) {
    String sql = "SELECT * FROM filmy WHERE zaner = " + zaner;
    BeanPropertyRowMapper<Film> mapper = BeanPropertyRowMapper.newInstance(Film.class);
    return jdbcTemplate.query(sql, mapper);
}

From source file:sk.upjs.ics.autobazar.MySqlInzeratKaravanDao.java

@Override
public List<InzeratKaravan> dajPodlaPouzivatela(Long idP) {
    String sql = "SELECT * FROM inzeratKaravan where idP = ?";
    BeanPropertyRowMapper<InzeratKaravan> mapper = BeanPropertyRowMapper.newInstance(InzeratKaravan.class);
    return jdbcTemplate.query(sql, mapper, idP);
}

From source file:com.example.dfa.demo.service.DfaDemoServiceImpl.java

@Autowired
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
    findWorkflowsSpaCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("sp_findEmployeeWorkflows")
            .withCatalogName("demo_employee")
            .returningResultSet("workflows", BeanPropertyRowMapper.newInstance(DfaWorkflowsDTO.class));

    getWorkflowsSpaCall = new SimpleJdbcCall(jdbcTemplate)
            .withProcedureName("sp_findWorkflowAndCurrentSubWorkflows").withCatalogName("demo_employee")
            .returningResultSet("workflows", BeanPropertyRowMapper.newInstance(DfaWorkflowsDTO.class));

    getSelectedEventsAndStatesSpaCall = new SimpleJdbcCall(jdbcTemplate)
            .withProcedureName("sp_selectWorkflowEventsAndStates").withCatalogName("demo_employee")
            .returningResultSet("events", BeanPropertyRowMapper.newInstance(SelectedEventsDTO.class))
            .returningResultSet("states", BeanPropertyRowMapper.newInstance(WorkflowStatesDTO.class));

    processWorkflowEventSpaCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("sp_processWorkflowEvent")
            .withCatalogName("demo_employee");

    insertEmployeeInsertStatement = new SimpleJdbcInsert(jdbcTemplate)
            .usingGeneratedKeyColumns("DFA_WORKFLOW_ID").withCatalogName("demo_employee")
            .withTableName("EMPLOYEE_PROSPECT");

    startWorkflowSpaCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("sp_startWorkflow")
            .withCatalogName("demo_employee");
}

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcVetRepositoryImpl.java

/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see com.branded.holdings.qpc.model.service.ClinicService#shouldFindVets()
 *//*from w w w.  ja va2 s.c  o  m*/
@Override
public Collection<Vet> findAll() throws DataAccessException {
    List<Vet> vets = new ArrayList<Vet>();
    // Retrieve the list of all vets.
    vets.addAll(
            this.jdbcTemplate.query("SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
                    BeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query("SELECT id, name FROM specialties",
            BeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
                "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
                new BeanPropertyRowMapper<Integer>() {
                    @Override
                    public Integer mapRow(ResultSet rs, int row) throws SQLException {
                        return Integer.valueOf(rs.getInt(1));
                    }
                }, vet.getId().intValue());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}