public Set<String> getCollectionRolesByEntityParticipant(String entityName) { return getCurrentSessionFactoryImplementor().getCollectionRolesByEntityParticipant(entityName); }
public BulkOperationCleanupAction(SessionImplementor session, Queryable[] affectedQueryables) { this.session = session; // TODO : probably better to calculate these and pass them in, as it'll be more performant ArrayList tmpSpaces = new ArrayList(); for ( int i = 0; i < affectedQueryables.length; i++ ) { if ( affectedQueryables[i].hasCache() ) { affectedEntityNames.add( affectedQueryables[i].getEntityName() ); } Set roles = session.getFactory().getCollectionRolesByEntityParticipant( affectedQueryables[i].getEntityName() ); if ( roles != null ) { affectedCollectionRoles.addAll( roles ); } for ( int y = 0; y < affectedQueryables[i].getQuerySpaces().length; y++ ) { tmpSpaces.add( affectedQueryables[i].getQuerySpaces()[y] ); } } this.spaces = new Serializable[ tmpSpaces.size() ]; for ( int i = 0; i < tmpSpaces.size(); i++ ) { this.spaces[i] = ( Serializable ) tmpSpaces.get( i ); } }
/** Create an action that will evict collection and entity regions based on queryspaces (table names). * TODO: cache the autodetected information and pass it in instead. **/ public BulkOperationCleanupAction(SessionImplementor session, Set querySpaces) { this.session = session; Set tmpSpaces = new HashSet(querySpaces); SessionFactoryImplementor factory = session.getFactory(); Iterator iterator = factory.getAllClassMetadata().entrySet().iterator(); while ( iterator.hasNext() ) { Map.Entry entry = (Map.Entry) iterator.next(); String entityName = (String) entry.getKey(); EntityPersister persister = factory.getEntityPersister( entityName ); Serializable[] entitySpaces = persister.getQuerySpaces(); if (affectedEntity( querySpaces, entitySpaces )) { if ( persister.hasCache() ) { affectedEntityNames.add( persister.getEntityName() ); } Set roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() ); if ( roles != null ) { affectedCollectionRoles.addAll( roles ); } for ( int y = 0; y < entitySpaces.length; y++ ) { tmpSpaces.add( entitySpaces[y] ); } } } this.spaces = (Serializable[]) tmpSpaces.toArray( new Serializable[tmpSpaces.size()] ); }