Example usage for org.springframework.jdbc.core JdbcTemplate query

List of usage examples for org.springframework.jdbc.core JdbcTemplate query

Introduction

In this page you can find the example usage for org.springframework.jdbc.core JdbcTemplate query.

Prototype

@Override
    public <T> List<T> query(String sql, RowMapper<T> rowMapper, @Nullable Object... args)
            throws DataAccessException 

Source Link

Usage

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by producer and video filename.
 *
 * @param producer the producer/* www. j  a  v  a2 s .  c o m*/
 * @param videoFileName the video file name
 * @return the by producer and video filename
 */
@SuppressWarnings("unchecked")
public List<Video> getByProducerAndVideoFilename(Producer producer, String videoFileName) {
    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video WHERE ( filename=? AND producerId=? )",
            new Object[] { videoFileName, producer.getId() }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the locked by lectureseries id.//from ww w  . j a v  a  2s  .co m
 *
 * @param lectureseriesId the lectureseries id
 * @return the locked by lectureseries id
 */
@SuppressWarnings("unchecked")
public List<Video> getLockedByLectureseriesId(int lectureseriesId) {
    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video WHERE lectureseriesId=? AND downloadLink=0 ORDER BY id DESC",
            new Object[] { lectureseriesId }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Filename exists.//from w  w w .  jav  a  2 s . c  o m
 *
 * @param filename the filename
 * @return true, if successful
 */
@SuppressWarnings("unchecked")
public boolean filenameExists(String filename) {
    String fn = "'%" + filename + "%'";
    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video  WHERE filename LIKE ?",
            new Object[] { fn }, new VideoRowMapper());
    boolean returN = false;
    if (result.size() > 0)
        returN = true;

    return returN;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by filename.//  ww  w . j  ava 2s  .  co  m
 *
 * @param filename the filename
 * @return the by filename
 */
@SuppressWarnings("unchecked")
public List<Video> getByFilename(String filename) {
    String fn = "'%" + filename + "%'";
    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video  WHERE filename LIKE ?",
            new Object[] { fn }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by open access and counter.//w w w.  ja  va  2  s  . c o  m
 *
 * @param start the start
 * @param ende the ende
 * @return the by open access and counter
 */
@SuppressWarnings("unchecked")
public List<Video> getByOpenAccessAndCounter(Integer start, Integer ende) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video WHERE openAccess=1 ORDER BY generationDate DESC LIMIT ?, ?;",
            new Object[] { start, ende }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by open access and counter and facility id.
 *
 * @param start the start//  www.  j a v  a  2  s  . c  om
 * @param ende the ende
 * @param facilityId the facility id
 * @return the by open access and counter and facility id
 */
@SuppressWarnings("unchecked")
public List<Video> getByOpenAccessAndCounterAndFacilityId(Integer start, Integer ende, Integer facilityId) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT * FROM video, video_facility WHERE (video.openAccess=1 AND video.id=video_facility.videoId AND video_facility.facilityId=?) ORDER BY id DESC LIMIT ?,?;",
            new Object[] { facilityId, start, ende }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by open access and facility id.
 *
 * @param facilityId the facility id// w w  w . jav  a  2  s.c  om
 * @return the by open access and facility id
 */
@SuppressWarnings("unchecked")
public List<Video> getByOpenAccessAndFacilityId(Integer facilityId) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT * FROM video, video_facility WHERE ( video.openAccess=1 AND video.id=video_facility.videoId AND video_facility.facilityId=? ) ORDER BY id DESC;",
            new Object[] { facilityId }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by open facility id./*from   w  ww. java 2s  . c  o  m*/
 *
 * @param facilityId the facility id
 * @return the by open facility id
 */
@SuppressWarnings("unchecked")
public List<Video> getByOpenFacilityId(Integer facilityId) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT * FROM video, video_facility WHERE ( video.id=video_facility.videoId AND video_facility.facilityId=? ) ORDER BY id DESC;",
            new Object[] { facilityId }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the locked by producer id.//ww w  .  ja v  a2s. co m
 *
 * @param remoteUserId the remote user id
 * @return the locked by producer id
 */
@SuppressWarnings("unchecked")
public List<Video> getLockedByProducerId(int remoteUserId) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video WHERE ( producerId=? AND downloadLink=0 ) ORDER BY id DESC",
            new Object[] { remoteUserId }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}

From source file:de.uhh.l2g.dao.VideoDao.java

/**
 * Gets the by open access and lectureseries id.
 *
 * @param lectureseriesId the lectureseries id
 * @param order the order/* ww w  .j a va 2s.  c  o  m*/
 * @return the by open access and lectureseries id
 */
@SuppressWarnings("unchecked")
public List<Video> getByOpenAccessAndLectureseriesId(Integer lectureseriesId, String order) {

    JdbcTemplate select = new JdbcTemplate(this.getDataSource());
    List<Video> result = select.query(
            "SELECT id, title, tags, lectureseriesId, ownerId, producerId, containerFormat, filename, resolution, duration, hostId, textId, filesize, generationDate, openAccess, downloadLink, metadataId, surl, hits, uploadDate, permittedToSegment, facilityId, citation2go FROM video WHERE (openAccess=1 AND lectureseriesId=?) ORDER BY generationDate "
                    + order,
            new Object[] { lectureseriesId }, new VideoRowMapper());
    try {
        this.fillVideoListWithProperties(result);
    } catch (IOException e) {
    }

    return result;
}