Results 1 to 2 of 2

Thread: through spring, catch the excepting then throws my exception

Hybrid View

  1. #1
    Join Date
    May 2005
    Posts
    1

    Default through spring, catch the excepting then throws my exception

    i want to throw myself exceptions through spring catch the exception
    so i define a DAOException

    try {
    getHibernateTemplate().save(user);
    }
    catch (DataAccessException ex) {

    if (ex instanceof DataIntegrityViolationException) {
    throw new DAOException("Primary?? key exception in which key??");
    }
    if (ex instanceof DataRetrievalFailureException) {
    throw new DAOException("connect exception");
    }
    }

    the question is:
    the spring doesn't differentiate "DataIntegrityViolationException" in detailed.
    i don't know which key confilcted or if there are more indexes,which index is confilcted or forgein key confilicted?
    what can i do??

    maginn

  2. #2
    Join Date
    Aug 2004
    Posts
    1,110

    Default

    Thats a general JDBC problem - we have to interpret the text in the message from the SQLException to determine which index/column is causing the problem. You might not even get the specific column but the name of a constraint. This part is dependent on which database you are using. So Spring can't really help you much here.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

Similar Threads

  1. Replies: 8
    Last Post: Jul 15th, 2007, 04:08 AM
  2. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  3. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  4. Replies: 2
    Last Post: Jan 21st, 2005, 04:17 AM
  5. Replies: 3
    Last Post: Nov 8th, 2004, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •