Example usage for org.springframework.dao.support DataAccessUtils singleResult

List of usage examples for org.springframework.dao.support DataAccessUtils singleResult

Introduction

In this page you can find the example usage for org.springframework.dao.support DataAccessUtils singleResult.

Prototype

@Nullable
public static <T> T singleResult(@Nullable Collection<T> results)
        throws IncorrectResultSizeDataAccessException 

Source Link

Document

Return a single result object from the given Collection.

Usage

From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java

@Override
public Integer getMedicationTypeId(String genericProductIdentification, String medicationTypeDescription) {
    final String sql = "SELECT medicationTypeId FROM MedicationType WHERE GenericProductIdentification = ? AND MedicationTypeDescription = ?";

    List<Integer> medicationTypeIds = jdbcTemplate.queryForList(sql, Integer.class,
            genericProductIdentification, medicationTypeDescription);

    return DataAccessUtils.singleResult(medicationTypeIds);
}

From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java

@Override
public Integer getBookingIdByBookingNumber(String bookingNumber) {
    final String sql = "SELECT b.bookingId FROM Booking b " + "WHERE bookingNumber = ?";

    List<Integer> bookingIds = jdbcTemplate.queryForList(sql, Integer.class, bookingNumber);

    return DataAccessUtils.singleResult(bookingIds);
}

From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java

@Override
public Person getPersonByBookingNumber(String bookingNumber) {
    final String sql = "SELECT * FROM Person p " + "LEFT JOIN Booking k ON k.PersonID = p.personID "
            + "LEFT JOIN PersonSexType s ON s.PersonSexTypeID = p.PersonSexTypeID "
            + "LEFT JOIN PersonRaceType r ON r.PersonRaceTypeID = p.PersonRaceTypeID "
            + "LEFT JOIN LanguageType l on l.languageTypeID = p.languageTypeID "
            + "LEFT JOIN HousingStatusType h ON h.HousingStatusTypeID = b.HousingStatusTypeID "
            + "LEFT JOIN EducationLevelType e ON e.EducationLevelTypeID = b.EducationLevelTypeID "
            + "LEFT JOIN OccupationType o on o.OccupationTypeID = b.OccupationTypeID "
            + "LEFT JOIN IncomeLevelType i on i.IncomeLevelTypeID = b.IncomeLevelTypeID "
            + "LEFT JOIN MilitaryServiceStatusType m on m.MilitaryServiceStatusTypeID = b.MilitaryServiceStatusTypeID "
            + "WHERE p.BookingNumber = ?";
    List<Person> persons = jdbcTemplate.query(sql, new PersonRowMapper(), bookingNumber);
    return DataAccessUtils.singleResult(persons);
}

From source file:org.ojbc.adapters.analyticsstaging.custody.dao.AnalyticalDatastoreDAOImpl.java

@Override
public CustodyRelease getCustodyReleaseByBookingNumber(String bookingNumber) {
    final String sql = "Select top 1 * from CustodyRelease where BookingNumber = ? order by CustodyReleaseTimestamp desc";

    List<CustodyRelease> custodyReleases = jdbcTemplate.query(sql, new CustodyReleaseRowMapper(),
            bookingNumber);//  w ww .j a v  a  2  s .  c  o  m
    return DataAccessUtils.singleResult(custodyReleases);
}

From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java

@Override
public Subject getSubject(Integer id) {
    final String SUBJECT_SELECT = "SELECT * FROM IDENTIFICATION_SUBJECT WHERE SUBJECT_ID = ?";

    List<Subject> subjects = jdbcTemplate.query(SUBJECT_SELECT, new SubjectRowMapper(), id);
    return DataAccessUtils.singleResult(subjects);
}

From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java

@Override
public IdentificationTransaction getIdentificationTransaction(String transactionNumber) {
    final String ID_TRANSACTION_SELECT_BY_TRANSACTION_NUMBER = " SELECT * FROM identification_transaction i "
            + "LEFT JOIN identification_subject s ON s.subject_id = i.subject_id "
            + "WHERE transaction_number = ?";

    List<IdentificationTransaction> transactions = jdbcTemplate.query(
            ID_TRANSACTION_SELECT_BY_TRANSACTION_NUMBER, new IdentificationTransactionRowMapper(),
            transactionNumber);/*from   ww  w . j  av a2 s . co m*/
    return DataAccessUtils.singleResult(transactions);
}

From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java

@Override
public Integer getCivilIntialResultsId(String transactionNumber, ResultSender resultSender) {
    final String CIVIL_INITIAL_RESULTS_ID_SELECT = "SELECT t.civiL_INITIAL_RESULT_ID  "
            + "FROM CIVIL_INITIAL_RESULTS t " + "WHERE t.TRANSACTION_NUMBER  = ? AND RESULTS_SENDER_ID = ?";

    List<Integer> ids = jdbcTemplate.queryForList(CIVIL_INITIAL_RESULTS_ID_SELECT, Integer.class,
            transactionNumber, resultSender.ordinal() + 1);

    return DataAccessUtils.singleResult(ids);
}

From source file:org.ojbc.adapters.rapbackdatastore.dao.RapbackDAOImpl.java

@Override
public String getIdentificationCategory(String transactionNumber) {
    log.info("Retrieving identification category by transaction number : " + transactionNumber);

    final String sql = "SELECT identification_category FROM identification_transaction t WHERE t.transaction_number = ?";

    List<String> results = jdbcTemplate.queryForList(sql, String.class, transactionNumber);

    return DataAccessUtils.singleResult(results);
}

From source file:org.ojbc.connectors.warrantmod.dao.WarrantsRepositoryBaseDaoImpl.java

@Override
public Warrant retrieveWarrant(Integer warrantId) {
    String sql = "SELECT w.*, wr.WarrantRemarkText from Warrant w "
            + "LEFT JOIN WarrantRemarks wr ON wr.warrantID = w.warrantID WHERE w.warrantID = ? ";

    List<Warrant> warrants = jdbcTemplate.query(sql, new WarrantResultSetExtractor(), warrantId);
    return DataAccessUtils.singleResult(warrants);
}

From source file:org.ojbc.intermediaries.sn.dao.rapback.FbiRapbackDao.java

public FbiRapbackSubscription getFbiRapbackSubscription(String category, String ucn) {

    logger.info("\n\n\n Using category: " + category + ", and ucn: " + ucn + "\n\n\n");

    if (StringUtils.isEmpty(category) || StringUtils.isEmpty(ucn)) {
        throw new IllegalArgumentException("category and ucn cannot be null.");
    }//from   ww w .j  a  v  a 2s  .c om

    List<FbiRapbackSubscription> fbiSubscriptions = jdbcTemplate.query(FBI_SUBSCRIPTION_SELECT,
            new FbiSubscriptionRowMapper(), category, ucn);

    return DataAccessUtils.singleResult(fbiSubscriptions);
}