I am reading through it Spring Recipes at this time, and am puzzled by one factor: Any exceptions are tossed like a subclass of DataAccessException, a RuntimeException you are not designed to try/catch.

What I am concerned about is issues that may happen, particularly with card inserts. If you are using something similar to SimpleJdbcTemplate each totally its very own transaction, which means you can't ensure a vital isn't within the table then do your place using getSimpleJdbcTemplare.update(), since the key might have been placed between your two queries.

Clearly this really is something one may wish to handle more beautifully than the usual RuntimeException inside a production system. How do we cope with that?

Thanks.

a RuntimeException you are not designed to try/catch.

States who? You do not have to trap RuntimeException, there is however nothing to prevent you doing the work, it's perfectly acceptable. There's, for instance, a subclass of DataAccessException known as RecoverableDataAccessException, that is particularly supposed to have been caught to ensure that a retry could be attempted. Additionally, there are OptimisticLockingFailureException, which addresses the next reason for transactional clashes because of positive securing, and may also be caught and handled particularly through the application.

If you are using something similar to SimpleJdbcTemplate each totally its own transaction

Not the case. If you are using Spring's transactional semantics, then SimpleJdbcTemplate (or whatever DAO component you utilize) will have fun playing the transaction, with full Acidity semantics when the database and transaction manage supports it (which most should). Within the situation of the example, you are able to perform a select for update (or whatever your database supports) follows by an insert, all within one transaction.

Spring's data access layer is most likely its best feature, however it rarely will get the loan for this.