Announcement Announcement Module
No announcement yet.
DataRetrievalFailureException versus IncorrectResultSizeD... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • DataRetrievalFailureException versus IncorrectResultSizeD...

    What is Spring's philosophy on throwing IncorrectResultSizeDataAccessException versus DataRetrievalFailureException. I ran JdbcTemplate's queryForInt() when the expected row was not found. The implementation throws IncorrectResultSizeDataAccessException when I was expecting DataRetrievalFailureException. Under what circumstances is DataRetrievalFailureException (or subclasses) thrown?


  • #2
    DataRetrievalFailureException will always be mapped to by things like the Hibernate error code mapper, the JDO mapper, etc., when you query for a particular object and that entity is not around. It's entirely appropriate for your DAO to throw it as well when something it's trying to load is not there (which should be).

    On the other hand, I would consider IncorrectResultSizeDataAccessException a lower level exception. It's thrown by the JDBC code when there are simply not enough rows of data, _or_ there are too many rows of data...

    I agree there is some overlap.