agave-systems/systems-core/src/main/java/org/iplantc/service/systems/dao/SystemRoleDao.java
/**
	 * Removes all {@link SystemRole} for a given {@link RemoteSystem} as a single sql update.
	 * @param remoteSystemId
	 * @throws RolePersistenceException
	 */
Removes all  SystemRole for a given  RemoteSystem as a single sql update.
Removes all SystemRole for a given RemoteSystem as a single sql update .
public static void clearSystemRoles(Long remoteSystemId) throws RolePersistenceException {
		if (!ServiceUtils.isValid(remoteSystemId))
			throw new RolePersistenceException("RemoteSystem id cannot be null");
		try
		{
			HibernateUtil.beginTransaction();
			Session session = HibernateUtil.getSession();
			session.clear();
			String hql = "DELETE SystemRole r WHERE r.remote_system.id = :systemid";
			session.createQuery(hql)
					.setLong("systemid", remoteSystemId)
					.executeUpdate();
			session.flush();
		}
		catch (HibernateException ex) {
			try {
				if (HibernateUtil.getSession().isOpen()) {
					HibernateUtil.rollbackTransaction();
				}
			}
			catch (Exception e) {}
			throw new RolePersistenceException(ex);
		}
		finally {
			try { HibernateUtil.commitTransaction();} catch (Exception e) {}
		}
	}
public static void clearSystemRoles ( Long remoteSystemId ) throws RolePersistenceException { if ( ! ServiceUtils . isValid ( remoteSystemId ) ) throw new RolePersistenceException ( "RemoteSystem id cannot be null" ) ; try { HibernateUtil . beginTransaction ( ) ; Session session = HibernateUtil . getSession ( ) ; session . clear ( ) ; String hql = "DELETE SystemRole r WHERE r.remote_system.id = :systemid" ; session . createQuery ( hql ) . setLong ( "systemid" , remoteSystemId ) . executeUpdate ( ) ; session . flush ( ) ; } catch ( HibernateException ex ) { try { if ( HibernateUtil . getSession ( ) . isOpen ( ) ) { HibernateUtil . rollbackTransaction ( ) ; } } catch ( Exception e ) { } throw new RolePersistenceException ( ex ) ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception e ) { } } }
Removes all {@link SystemRole} for a given {@link RemoteSystem} as a single sql update.
Removes all { @link SystemRole } for a given { @link RemoteSystem } as a single sql update .