* There was a problem initializing one of the DAOs.
*/
private final void initDaos(final SqlDaoInterface... daoInterfaces) {
// Create a transaction manager.
PlatformTransactionManager transactionManager =
new DataSourceTransactionManager(dataSource);
// Create a new transaction definition and name it.
DefaultTransactionDefinition transactionDefinition =
new DefaultTransactionDefinition();
transactionDefinition
.setName("Initializing the Open mHealth DAO database tables.");
// Create the new transaction.
TransactionStatus transactionStatus =
transactionManager.getTransaction(transactionDefinition);
// Create the table if it does not exist.
try {
for(SqlDaoInterface daoInterface : daoInterfaces) {
// Create the table if it does not exist.
jdbcTemplate.execute(daoInterface.getSqlTableDefinition());
}
}
// If creating the table fails, roll back the transaction and error
// out.
catch(DataAccessException e) {
transactionManager.rollback(transactionStatus);
throw
new IllegalStateException(
"There was an issue creating a DAO table definition.",
e);
}
// TODO: This is where the DAO interface's update scripts would
// be run.
// Commit the transaction.
try {
transactionManager.commit(transactionStatus);
}
catch(TransactionException e) {
transactionManager.rollback(transactionStatus);
throw
new IllegalStateException(
"There was an error committing the transaction.",
e);
}