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:com.reactivetechnologies.platform.datagrid.store.ModelJdbcRepository.java

@Override
public <S extends RegressionModel> S save(S entity) {
    Assert.notNull(entity);//from w ww.  j  a v  a  2  s.co m
    String dml = "insert into RD_MODEL_SNAPSHOT (CREATED_TS,MODEL,GEN_ID) values (now(),?,?) ";
    log.debug("Firing insert: " + dml);
    try {
        jdbcTemplate.update(dml, entity.serializeClassifierAsJson(), entity.getLongId());
    } catch (DuplicateKeyException dup) {
        log.warn("Model already exists in database. Ignoring save failure");
    } catch (Exception e) {
        throw new DataAccessException("Cannot serialize ensemble classifier to disk", e) {

            /**
             * 
             */
            private static final long serialVersionUID = 1L;
        };
    }
    return entity;
}

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

@Override
public void delete(Baggage entity) {
    try {//ww  w .  j av  a 2  s. co m
        Util.validateBaggage(entity);

        if (entity.getId() == null) {
            throw new IllegalArgumentException("This plane entity cannot have null id.");
        }
        if (em.find(Plane.class, entity.getId()) == null) {
            throw new IllegalArgumentException("This plane entity does not exist in database.");
        }

        Baggage objectTemp = em.merge(entity);

        em.remove(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 Seat getById(Long id) {
    try {/*from   www . j  a  v  a 2s .  c om*/
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

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

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

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

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

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

@Override
public Baggage getById(Long id) {
    try {//  w  ww.j a  va2  s .  c  om
        if (id == null) {
            throw new IllegalArgumentException("Id cannot be null.");
        }

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

From source file:com.reactivetechnologies.analytics.store.ModelJdbcRepository.java

@Override
public <S extends RegressionModel> S save(S entity) {
    Assert.notNull(entity);/* ww w.ja  va 2  s . co m*/
    log.debug("Firing insert: " + INSERT_MODEL);
    try {
        jdbcTemplate.update(INSERT_MODEL, entity.serializeClassifierAsJson(), entity.getStringId());
    } catch (IOException e) {
        throw new DataAccessException("Unable to serialze model to string", e) {

            /**
             * 
             */
            private static final long serialVersionUID = 1L;
        };
    }
    return entity;
}

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

@Override
public void delete(SeatReservation entity) {
    try {//  www.j a v  a 2s  . c  o  m

        if (entity.getId() == null) {
            throw new IllegalArgumentException("This plane entity cannot have null id.");
        }
        if (em.find(SeatReservation.class, entity.getId()) == null) {
            throw new IllegalArgumentException("This plane entity does not exist in database.");
        }

        SeatReservation objectTemp = em.merge(entity);

        em.remove(objectTemp);
    } catch (PersistenceException | IllegalArgumentException ex) {
        throw new DataAccessException(ex.getMessage(), ex) {
        };
    }
}

From source file:org.spring.data.gemfire.app.dao.provider.JdbcUserDao.java

protected DataAccessException createDataAccessException(final String message, final Throwable cause) {
    return new DataAccessException(message, cause) {
    };//from  w ww.j a  v  a 2 s . co m
}

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

@Override
public List<Seat> getAll() {
    try {//w  w  w. j av  a 2  s  . co  m
        Query q = em.createQuery("FROM Seat");
        List<Seat> planes = q.getResultList();

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

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

@Override
public List<Plane> getAll() {
    try {// w w  w. j av  a2 s  . c o  m
        Query q = em.createQuery("FROM Plane");
        List<Plane> planes = q.getResultList();

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