Example usage for org.springframework.dao DataAccessException DataAccessException

List of usage examples for org.springframework.dao DataAccessException DataAccessException

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException DataAccessException.

Prototype

public DataAccessException(String msg) 

Source Link

Document

Constructor for DataAccessException.

Usage

From source file:cz.muni.pa165.carparkapp.DAOImpl.CarDAOImpl.java

@Override
public List<Car> getAllCars() {
    List<Car> cars = null;//from   ww  w  .j  a  v  a 2  s.  c  o  m
    try {
        cars = em.createQuery("SELECT c FROM Car c", Car.class).getResultList();
    } catch (Exception e) {
        throw new DataAccessException("Query thrown exception") {
        };
    }
    return cars;
}

From source file:cz.muni.pa165.carparkapp.DAOImpl.EmployeeDAOImpl.java

@Override
public List<Employee> getAllEmployees() {
    List<Employee> employees = null;
    try {/*from ww w  .j a  v  a 2 s  .  c  om*/
        employees = em.createQuery("SELECT e FROM Employee e", Employee.class).getResultList();
    } catch (Exception e) {
        throw new DataAccessException("Exception during getting Employees from DB") {
        };
    }
    return employees;
}

From source file:annis.dao.SpringAnnisDao.java

@Override
public String mapCorpusIdToName(long corpusId) {

    List<Long> ids = new ArrayList<>();
    ids.add(corpusId);//from w  w  w. j  av a  2 s . co  m
    List<String> names = mapCorpusIdsToNames(ids);

    if (names == null || names.isEmpty()) {
        String msg = "corpus is not known to the system";
        throw new DataAccessException(msg) {
        };
    }

    return names.get(0);

}