public void delete()
throws SQLException
{
final DBCache<UUID,Group> groupCache = db.realmGroupCaches.get(this);
final DBCache<UUID,RealmUser> userCache = db.realmUserCaches.get(this);
DBConnection connection = db.getConnection();
try {
connection.query(AuthDB.GROUP_BY_REALM,new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id);
}
public void onResults(ResultSet set)
throws SQLException
{
while (set.next()) {
Group group = groupCache.get(set.getInt(1));
group.delete();
}
}
});
connection.query(AuthDB.REALM_USER_BY_REALM,new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,id);
}
public void onResults(ResultSet set)
throws SQLException
{
while (set.next()) {
RealmUser user = userCache.get(set.getInt(1));
user.delete();
}
}
});
connection.deleteById(AuthDB.DELETE_AUTHENTICATED_BY_REALM, id);
connection.deleteById(AuthDB.DELETE_REALM, id);
db.realmCache.remove(id);
db.realmUserCaches.remove(this);
db.realmGroupCaches.remove(this);
} finally {
db.release(connection);