Announcement Announcement Module
Collapse
No announcement yet.
Which DataAccessException == "Failed to create/delete d Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Create your own exceptions that subclass DataAccessException.

    Comment


    • #3
      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!

      Comment


      • #4
        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

        Comment


        • #5
          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".

          Comment


          • #6
            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.

            Comment

            Working...
            X