public T get(String id, Object val) throws PersistenceException {
        logger.debug("enter - get(String,Object)");
        if( logger.isDebugEnabled() ) {
            logger.debug("For: " + cache.getTarget().getName() + "/" + id + "/" + val);
        }
        try {
            Class<? extends Execution> cls;
            CacheLoader<T> loader;
            
            loader = new CacheLoader<T>() {
                public T load(Object ... args) {
                    SearchTerm[] terms = new SearchTerm[1];
                    Collection<T> list;
                    
                    terms[0] = new SearchTerm((String)args[0], Operator.EQUALS, args[1]);
                    try {
                        list = PersistentFactory.this.load(singletons.get(args[0]), null, terms);
                    }
                    catch( PersistenceException e ) {
                        try {
                            try { Thread.sleep(1000L); }
                            catch( InterruptedException ignore ) { }
                            list = PersistentFactory.this.load(singletons.get(args[0]), null, terms);
                        }
                        catch( Throwable forgetIt ) {
                            logger.error(forgetIt.getMessage(), forgetIt);
                            throw new RuntimeException(e);
                        }
                    }
                    if( list.isEmpty() ) {
                        return null;
                    }
                    return list.iterator().next();
                }
            };
            synchronized( this ) {
                while( !singletons.containsKey(id) ) {
                    SearchTerm[] terms = new SearchTerm[1];
                    
                    terms[0] = new SearchTerm(id, Operator.EQUALS, val);
                    compileLoader(terms, singletons, null);
                    try { wait(100L); }
                    catch( InterruptedException ignore ) { /* ignore this */ }
                }
                cls = singletons.get(id);
            }            
            if( cls == null ) {
                throw new PersistenceException("Queries on the field " + id + " will not return single values.");
            }
            logger.debug("Executing cache find...");
            try {
                return cache.find(id, val, loader, id, val);
            }
            catch( CacheManagementException e ) {
                throw new PersistenceException(e);
            }
            catch( RuntimeException e ) {
                Throwable t = e.getCause();
                
                if( t != null && t instanceof PersistenceException ) {
                    throw (PersistenceException)t;
                }
                if( logger.isDebugEnabled() ) {
                    logger.error(e.getMessage(), e);
                }
                throw new PersistenceException(e);
            }
            finally {
                logger.debug("Executed.");
            }
        }
        finally {
            logger.debug("exit - get(String,Object)");
        }
    }
public T get ( String id , Object val ) throws PersistenceException { logger . debug ( "enter - get(String,Object)" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "For: " + cache . getTarget ( ) . getName ( ) + "/" + id + "/" + val ) ; } try { Class < ? extends Execution > cls ; CacheLoader < T > loader ; loader = new CacheLoader < T > ( ) { public T load ( Object ... args ) { SearchTerm [ ] terms = new SearchTerm [ 1 ] ; Collection < T > list ; terms [ 0 ] = new SearchTerm ( ( String ) args [ 0 ] , Operator . EQUALS , args [ 1 ] ) ; try { list = PersistentFactory . this . load ( singletons . get ( args [ 0 ] ) , null , terms ) ; } catch ( PersistenceException e ) { try { try { Thread . sleep ( 1000L ) ; } catch ( InterruptedException ignore ) { } list = PersistentFactory . this . load ( singletons . get ( args [ 0 ] ) , null , terms ) ; } catch ( Throwable forgetIt ) { logger . error ( forgetIt . getMessage ( ) , forgetIt ) ; throw new RuntimeException ( e ) ; } } if ( list . isEmpty ( ) ) { return null ; } return list . iterator ( ) . next ( ) ; } } ; synchronized ( this ) { while ( ! singletons . containsKey ( id ) ) { SearchTerm [ ] terms = new SearchTerm [ 1 ] ; terms [ 0 ] = new SearchTerm ( id , Operator . EQUALS , val ) ; compileLoader ( terms , singletons , null ) ; try { wait ( 100L ) ; } catch ( InterruptedException ignore ) { } } cls = singletons . get ( id ) ; } if ( cls == null ) { throw new PersistenceException ( "Queries on the field " + id + " will not return single values." ) ; } logger . debug ( "Executing cache find..." ) ; try { return cache . find ( id , val , loader , id , val ) ; } catch ( CacheManagementException e ) { throw new PersistenceException ( e ) ; } catch ( RuntimeException e ) { Throwable t = e . getCause ( ) ; if ( t != null && t instanceof PersistenceException ) { throw ( PersistenceException ) t ; } if ( logger . isDebugEnabled ( ) ) { logger . error ( e . getMessage ( ) , e ) ; } throw new PersistenceException ( e ) ; } finally { logger . debug ( "Executed." ) ; } } finally { logger . debug ( "exit - get(String,Object)" ) ; } }
Retrieves the object uniquely identified by the value for the specified ID field.
@param id the ID field identifying the object
@param val the value that uniquely identifies the desired object
@return the object matching the query criterion
@throws PersistenceException an error occurred talking to the data store