Skip to content

Instantly share code, notes, and snippets.

@timoyuen
Forked from mdellabitta/gist:1444003
Created March 5, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timoyuen/9368562 to your computer and use it in GitHub Desktop.
Save timoyuen/9368562 to your computer and use it in GitHub Desktop.
public class ExodusWriter {
private JdbcTemplate jdbcTemplate;
private TransactionTemplate transactionTemplate;
public ExodusWriter(DataSource dataSource) {
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
jdbcTemplate = new JdbcTemplate(transactionManager.getDataSource());
transactionTemplate = new TransactionTemplate(transactionManager);
}
public void writeImageID(final String imageID, final String uuid) throws Exception {
transactionTemplate.execute(new TransactionCallback<Object>() {
@Override
public Object doInTransaction(TransactionStatus status) {
jdbcTemplate.update("delete from image_to_uuid where image_id = ?", imageID);
jdbcTemplate.update("insert into image_to_uuid (image_id, uuid) values (?, ?)", imageID, uuid);
return null;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment