Source:
public void addUserSubscription(final NodeSubscription subscription) throws NodeStoreException { PreparedStatement deleteStatement = null; PreparedStatement updateStatement = null; PreparedStatement addStatement = null; Transaction t = null; try { if (subscription.getSubscription().equals(Subscriptions.none)) { deleteStatement = conn.prepareStatement(dialect.deleteSubscription()); deleteStatement.setString(1, subscription.getNodeId()); deleteStatement.setString(2, subscription.getUser().toBareJID()); deleteStatement.executeUpdate(); deleteStatement.close(); } else { t = beginTransaction(); updateStatement = conn.prepareStatement(dialect.updateSubscription()); updateStatement.setString(1, subscription.getSubscription().toString()); updateStatement.setString(2, subscription.getListener().toString()); updateStatement.setString(3, subscription.getNodeId()); updateStatement.setString(4, subscription.getUser().toBareJID()); int rows = updateStatement.executeUpdate(); updateStatement.close(); if (rows == 0) { addStatement = conn.prepareStatement(dialect.insertSubscription()); addStatement.setString(1, subscription.getNodeId()); addStatement.setString(2, subscription.getUser().toBareJID()); addStatement.setString(3, subscription.getListener().toString()); addStatement.setString(4, subscription.getSubscription().toString()); if (null == subscription.getInvitedBy()) { addStatement.setNull(5, Types.NULL); } else { addStatement.setString(5, subscription.getInvitedBy().toBareJID()); } addStatement.executeUpdate(); addStatement.close(); } t.commit(); } } catch (SQLException e) { LOGGER.debug("Error adding new subscription: " + e.getMessage()); throw new NodeStoreException(e); } finally { close(deleteStatement); close(updateStatement); close(addStatement); close(t); } }

Target:
public void addUserSubscription(final NodeSubscription subscription) throws NodeStoreException { PreparedStatement deleteStatement = null; PreparedStatement updateStatement = null; PreparedStatement addStatement = null; Transaction t = null; try { if (subscription.getSubscription().equals(Subscriptions.none)) { deleteStatement = conn.prepareStatement(dialect.deleteSubscription()); deleteStatement.setString(1, subscription.getNodeId()); deleteStatement.setString(2, subscription.getUser().toBareJID()); deleteStatement.executeUpdate(); deleteStatement.close(); } else { t = beginTransaction(); updateStatement = conn.prepareStatement(dialect.updateSubscription()); updateStatement.setString(1, subscription.getSubscription().toString()); updateStatement.setString(2, subscription.getListener().toString()); updateStatement.setString(3, subscription.getNodeId()); updateStatement.setString(4, subscription.getUser().toBareJID()); int rows = updateStatement.executeUpdate(); updateStatement.close(); if (rows == 0) { addStatement = conn.prepareStatement(dialect.insertSubscription()); addStatement.setString(1, subscription.getNodeId()); addStatement.setString(2, subscription.getUser().toBareJID()); addStatement.setString(3, subscription.getListener().toString()); addStatement.setString(4, subscription.getSubscription().toString()); if (null == subscription.getInvitedBy()) { addStatement.setNull(5, Types.NULL); } else { addStatement.setString(5, subscription.getInvitedBy().toBareJID()); } addStatement.executeUpdate(); addStatement.close(); } t.commit(); } } catch (SQLException e) { LOGGER.debug("Error adding new subscription: " + e.getMessage(), e); throw new NodeStoreException(e); } finally { close(deleteStatement); close(updateStatement); close(addStatement); close(t); } }