List of usage examples for org.springframework.dao DataAccessException DataAccessException
public DataAccessException(@Nullable String msg, @Nullable Throwable cause)
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.AdministratorDaoImpl.java
@Override public List<Administrator> getAll() { try {/*from w ww. j av a 2 s . c o m*/ Query q = em.createQuery("FROM Administrator"); List<Administrator> objectTemp = q.getResultList(); return Collections.unmodifiableList(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 List<FlightTicketPrice> getAll() { try {/* w w w . java2 s . c om*/ Query q = em.createQuery("FROM FlightTicketPrice"); List<FlightTicketPrice> objectTemp = q.getResultList(); return Collections.unmodifiableList(objectTemp); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatReservationDaoImpl.java
@Override public void create(SeatReservation entity) { try {// w w w. ja v a 2 s . co m if (entity.getFlightTicket() == null) { throw new IllegalArgumentException("Flight ticket must be defined."); } if (entity.getSeat() == null) { throw new IllegalArgumentException("Seat number must be defined."); } 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 List<Airline> getAll() { try {// www. jav a 2s . co m Query q = em.createQuery("FROM Airline"); List<Airline> objectTemp = q.getResultList(); return Collections.unmodifiableList(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 update(Seat entity) { try {/*from ww w . ja v a 2 s .c o m*/ Util.validateSeat(entity); if (entity.getId() == null) { throw new IllegalArgumentException("This seat entity cannot have null id."); } if (em.find(Seat.class, entity.getId()) == null) { throw new IllegalArgumentException("This seat entity does not exist in database."); } em.merge(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 update(Plane entity) { try {//from w w w . j av a2s .co m Util.validatePlane(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."); } em.merge(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.BaggageDaoImpl.java
@Override public void update(Baggage entity) { try {/* w ww . j ava 2 s .co m*/ Util.validateBaggage(entity); if (entity.getId() == null) { throw new IllegalArgumentException("This baggage entity cannot have null id."); } if (em.find(Plane.class, entity.getId()) == null) { throw new IllegalArgumentException("This baggage entity does not exist in database."); } em.merge(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.SeatReservationDaoImpl.java
@Override public void update(SeatReservation entity) { try {/*w w w .java 2 s .com*/ if (entity.getFlightTicket() == null) { throw new IllegalArgumentException("Flight ticket must be defined."); } if (entity.getSeat() == null) { throw new IllegalArgumentException("Seat number must be defined."); } if (entity.getId() == null) { throw new IllegalArgumentException("This seat reservation entity cannot have null id."); } if (em.find(SeatReservation.class, entity.getId()) == null) { throw new IllegalArgumentException("This seat reservation entity does not exist in database."); } em.merge(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.SeatDaoImpl.java
@Override public void delete(Seat entity) { try {//from ww w.jav a2 s.co m Util.validateSeat(entity); if (entity.getId() == null) { throw new IllegalArgumentException("This plane entity cannot have null id."); } if (em.find(Seat.class, entity.getId()) == null) { throw new IllegalArgumentException("This plane entity does not exist in database."); } Seat 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.PlaneDaoImpl.java
@Override public void delete(Plane entity) { try {//from w w w .j a va2 s . c om Util.validatePlane(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."); } Plane objectTemp = em.merge(entity); em.remove(objectTemp); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }