Results 1 to 6 of 6

Thread: Which DataAccessException == "Failed to create/delete d

  1. #1
    Join Date
    Apr 2005
    Posts
    23

    Default Which DataAccessException == "Failed to create/delete d

    I'm reworking our system to replace SLBs with Spring DAOs and POJOs.

    I have a session bean method that creates and deletes records and currently throws CreateException and RemoveException.

    In my Springified DAO version of this logic, what should I throw to represent these conditions? I looked for analagous exception types in Spring but did not find anything.

    Any ideas?

    Thanks!

  2. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    Create your own exceptions that subclass DataAccessException.

  3. #3
    Join Date
    Apr 2005
    Posts
    23

    Default Thanks

    OK, will do.

    It just seems funny that I need to - aren't these common types of errors that people find interesting in general?

    Thanks!

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

    Default

    The Spring DataAccessException hierarchy is geared to inform you on what went wrong on the data store side. It's not geared to tell you in what context this error happened since that is usually known by the application based on where the error happened. Also Spring JDBC layer does not really know what is in your SQL statement - a delete or an insert is just part of the SQL string, so it can't reaally give you this context information anyway. If you want this type of information in your application, then you will have to add this layer in your DAO
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  5. #5
    Join Date
    Apr 2005
    Posts
    23

    Default I see

    I think I understand. Thank you.

    This leads me to ask "Am I properly using DataRetrievalFailureException?" I'm using it as the replacement for the EJB ObjectNotFoundException -- ie "Could not load the record with the provided id".

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

    Default

    That works. You could also use the more specific "ObjectRetrievalFailureException". This is the exeception used in the O/R Mapping support when an object is not found.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

Similar Threads

  1. Replies: 1
    Last Post: May 27th, 2005, 09:14 PM
  2. catching DataAccessException
    By Cuball in forum Data
    Replies: 3
    Last Post: May 20th, 2005, 07:40 AM
  3. Replies: 38
    Last Post: May 11th, 2005, 02:49 PM
  4. Replies: 2
    Last Post: Mar 11th, 2005, 05:17 AM

Posting Permissions

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