Package org.springframework.dao

Examples of org.springframework.dao.DataAccessException


    }

    if (exception instanceof RuntimeException)
      return (RuntimeException) exception;

    return new DataAccessException("unexpected exception ", exception) {
    };
  }
View Full Code Here


   * @return
   */
  public RuntimeException convertJbpmException(JbpmException ex) {
    // decode nested exceptions
    if (ex.getCause() instanceof HibernateException) {
      DataAccessException rootCause = SessionFactoryUtils.convertHibernateAccessException((HibernateException) ex.getCause());
      return rootCause;
    }

    // cannot convert the exception in any meaningful way
    return ex;
View Full Code Here

    if (ex instanceof HibernateException) {
      return SessionFactoryUtils.convertHibernateAccessException((HibernateException) ex);
    }

    if (ex.getCause() instanceof HibernateException) {
      DataAccessException rootCause = SessionFactoryUtils.convertHibernateAccessException((HibernateException) ex.getCause());
      return new NestedDataAccessException(ex.getMessage(), rootCause);
    }

    // cannot convert the exception in any meaningful way
    return ex;
View Full Code Here

            LOGGER.debug("Transaction synchronization committing SqlSession [" + this.holder.getSqlSession() + "]");
          }
          this.holder.getSqlSession().commit();
        } catch (PersistenceException p) {
          if (this.holder.getPersistenceExceptionTranslator() != null) {
            DataAccessException translated = this.holder
                .getPersistenceExceptionTranslator()
                .translateExceptionIfPossible(p);
            if (translated != null) {
              throw translated;
            }
View Full Code Here

    public void tearDown() {
    }

    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithNullArgument() {
        when(mockReservationDAO.insertReservation(null)).thenThrow(new DataAccessException("Null argument") {});
       
        reservationService.insertReservation(null);
    }
View Full Code Here

    }
   
    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithIncorrectReaderID() {  
        when(reservation1TO.getReaderTO().getId()).thenReturn(new Long(-5));
        when(mockReservationDAO.insertReservation(reservation1)).thenThrow(new DataAccessException("Incorrect reader") {});
       
        reservationService.insertReservation(reservation1TO);
    }
View Full Code Here

    }
   
    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithNullReaderID() {
        when(reservation1TO.getReaderTO().getId()).thenReturn(null);
        when(mockReservationDAO.insertReservation(reservation1)).thenThrow(new DataAccessException("Null reader") {});
       
        reservationService.insertReservation(reservation1TO);
   
View Full Code Here

   
   
    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithIncorrectBookID() {
        when(reservation1TO.getBookTO().getId()).thenReturn(new Long(-5));
        when(mockReservationDAO.insertReservation(reservation1)).thenThrow(new DataAccessException("Incorrect book") {});
       
        reservationService.insertReservation(reservation1TO);
   
View Full Code Here

   
   
    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithNullBookID() {
        when(reservation1TO.getBookTO().getId()).thenReturn(new Long(-5));
        when(mockReservationDAO.insertReservation(reservation1)).thenThrow(new DataAccessException("Null book") {});
       
        reservationService.insertReservation(reservation1TO);
    }
View Full Code Here

    }
   
    @Test(expected = DataAccessException.class)
    public void testInsertReservationWithIncorrectReservationDate() {
        when(reservation1TO.getReservationDate()).thenReturn(null);
        when(mockReservationDAO.insertReservation(reservation1)).thenThrow(new DataAccessException("Incorrect reservation date") {});
       
        reservationService.insertReservation(reservation1TO);
    }
View Full Code Here

TOP

Related Classes of org.springframework.dao.DataAccessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.