I'm reading the book Spring Recipes right now, and am puzzled by one thing: Any exceptions are thrown as a subclass of DataAccessException, a RuntimeException you're not meant to try/catch.
What I'm worried about is problems that are more likely to happen, especially with inserts. If you're using something like SimpleJdbcTemplate each query is its own transaction, so you can't ensure a key is not in the table then do your insert using getSimpleJdbcTemplare.update(), because the key could have been inserted between the two queries.
Obviously this is something one would want to handle more gracefully than a RuntimeException in a production system. So how do you deal with that?
Thanks.