@Transaction(TransactionIsolationLevel.SERIALIZABLE) public Optional<List<KeyRecord>> get(String number, long deviceId) { final KeyRecord record = retrieveFirst(number, deviceId); if (record != null && !record.isLastResort()) { removeKey(record.getId()); } else if (record == null) { return Optional.empty(); } List<KeyRecord> results = new LinkedList<>(); results.add(record); return Optional.of(results); }
@Transaction(TransactionIsolationLevel.SERIALIZABLE) public Optional<List<KeyRecord>> get(String number) { List<KeyRecord> preKeys = retrieveFirst(number); if (preKeys != null) { for (KeyRecord preKey : preKeys) { if (!preKey.isLastResort()) { removeKey(preKey.getId()); } } } if (preKeys != null) return Optional.of(preKeys); else return Optional.empty(); }
@Transaction(TransactionIsolationLevel.SERIALIZABLE) public void store(String number, long deviceId, List<PreKey> keys) { List<KeyRecord> records = new LinkedList<>(); for (PreKey key : keys) { records.add(new KeyRecord(0, number, deviceId, key.getKeyId(), key.getPublicKey(), false)); } removeKeys(number, deviceId); append(records); }
@Transaction(TransactionIsolationLevel.SERIALIZABLE) public boolean create(Account account) { int rows = removeAccount(account.getNumber()); insertStep(account); return rows == 0; }
@Transaction public Something failed(int id, String name) throws IOException { insert(id, name); throw new IOException("woof"); } }
@Transaction public void insertInNestedTransaction(final int id, final String name) { insertInSingleTransaction(id, name); }
@Transaction public void insert(CountDownLatch inserted, int id, String name) throws InterruptedException { reallyInsert(id, name); inserted.countDown(); }
@Transaction public void insert(CountDownLatch inserted, int id, String name) throws InterruptedException { reallyInsert(id, name); inserted.countDown(); }
@Transaction public Something insertAndFetchWithNestedTransaction(int id, String name) { return insertAndFetch(id, name); }
@Transaction public Something insertAndFetchWithNestedTransaction(int id, String name) { return insertAndFetch(id, name); }
@Transaction public void insertInSingleTransaction(final int id, final String name) { insert(id, name); }
@Transaction public Something failed(int id, String name) throws IOException { insert(id, name); throw new IOException("woof"); } }
@Transaction public Something failed(int id, String name) throws IOException { insert(id, name); throw new IOException("woof"); } }
@Transaction(TransactionIsolationLevel.READ_COMMITTED) public Something insertAndFetch(int id, String name) { insert(id, name); return findById(id); }
@Transaction(TransactionIsolationLevel.READ_COMMITTED) public Something insertAndFetch(int id, String name) { insert(id, name); return findById(id); }
@Transaction public int update(QuboleDbSource db, DataSourceDAO dao, Encrypt encrypt) { try { db.setUrl(encrypt.convertToDatabaseColumn(db.getUrl())); db.setAuthToken(encrypt.convertToDatabaseColumn(db.getAuthToken())); } catch (SQLException e) { throw new RuntimeException(e); } updateQubole(db); return dao.update(db); } }
@Override @Transaction public Address save(Address address) { if (address.getId() == null) { long id = insert(address); return get(id); } else { update(address); return get(address.getId()); } }
@Transaction public Something insertAndFail(int id, String name) { insert(id, name); return createBar().explode(); } }
@Transaction public Something insertAndFind(int id, String name) { insert(id, name); return createBar().findById(id); }
@Transaction public Something insertAndFind(int id, String name) { insert(id, name); return createBar().findById(id); }