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(@Nullable String msg, @Nullable Throwable cause) 

Source Link

Document

Constructor for DataAccessException.

Usage

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.AirlineDaoImpl.java

@Override
public Airline getById(Long id) {
    try {/*from   w  w  w . java  2s. c  o m*/
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

        Airline objectTemp = (Airline) em.find(Airline.class, id);
        return objectTemp;
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.CityDaoImpl.java

@Override
public City getById(Long id) {
    try {/*from  w w w.  ja  v  a2s  .c  o m*/
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

        City objectTemp = (City) em.find(City.class, id);
        return objectTemp;
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.AdministratorDaoImpl.java

@Override
public Administrator getById(Long id) {
    try {//from w w  w  . ja v a 2 s. com
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

        Administrator objectTemp = (Administrator) em.find(Administrator.class, id);
        return objectTemp;
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.FlightTicketPriceDaoImpl.java

@Override
public FlightTicketPrice getById(Long id) {
    try {//from w  ww  .java2 s .  co m
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

        FlightTicketPrice objectTemp = (FlightTicketPrice) em.find(FlightTicketPrice.class, id);
        return objectTemp;
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatDaoImpl.java

@Override
public void create(Seat entity) {
    try {//  w  w w  .j  ava2  s .c o m
        Util.validateSeat(entity);

        if (entity.getId() != null) {
            throw new IllegalArgumentException("This flight entity is already in database.");
        }

        em.persist(entity);
        em.flush();
        em.detach(entity);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.PlaneDaoImpl.java

@Override
public void create(Plane entity) {
    try {/* ww  w .  ja  va  2  s.c  om*/
        Util.validatePlane(entity);

        if (entity.getId() != null) {
            throw new IllegalArgumentException("This flight entity is already in database.");
        }

        em.persist(entity);
        em.flush();
        em.detach(entity);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:am.ik.support.morphia.spring.MorphiaDataStoreFactoryBean.java

@SuppressWarnings("serial")
@Override// w w w.  j  ava2 s.com
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    return new DataAccessException("Exception occured", ex) {
    };
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.BaggageDaoImpl.java

@Override
public void create(Baggage entity) {
    try {/*from   w w  w  .  ja v a2  s .  c o m*/
        Util.validateBaggage(entity);

        if (entity.getId() != null) {
            throw new IllegalArgumentException("This flight entity is already in database.");
        }

        em.persist(entity);
        em.flush();
        em.detach(entity);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.AirlineDaoImpl.java

@Override
public Airline getMainAirline() {
    try {/*from  ww  w . j  a  v a2s.c o m*/
        Query q = em.createQuery("FROM Airline WHERE main_airline='1'");
        Airline airlineTemp = (Airline) q.getSingleResult();

        return airlineTemp;
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.CityDaoImpl.java

@Override
public List<City> getAll() {
    try {//from   w w  w . jav  a 2  s. c o m
        Query q = em.createQuery("FROM City");
        List<City> objectTemp = q.getResultList();

        return Collections.unmodifiableList(objectTemp);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}