code: public DescriptorRepository getRepository()
      {
          DescriptorRepository repository;
          if (enablePerThreadChanges)
          {
              repository = (DescriptorRepository) threadedRepository.get();
              if (repository == null)
              {
                  repository = getGlobalRepository();
                  log.info(MSG_STR);
              }
  // arminw:
  // TODO: Be more strict in per thread mode and throw a exception when not find descriptor for calling thread?
  //            if (repository == null)
  //            {
  //                throw new MetadataException("Can't find a DescriptorRepository for current thread, don't forget" +
  //                        " to set a DescriptorRepository if enable per thread changes before perform other action");
  //            }
              return repository;
          }
          else
          {
              return globalRepository;
          }
      }
docs: Returns the current valid {@link org.apache.ojb.broker.metadata.DescriptorRepository} for
  the caller. This is the provided way to obtain the
  {@link org.apache.ojb.broker.metadata.DescriptorRepository}.
  <br>
  When {@link #isEnablePerThreadChanges per thread descriptor handling}  is enabled
  it search for a specific {@link org.apache.ojb.broker.metadata.DescriptorRepository}
  for the calling thread, if none can be found the global descriptor was returned.
  
  @see MetadataManager#getGlobalRepository
  @see MetadataManager#copyOfGlobalRepository