Created
          May 14, 2013 20:26 
        
      - 
      
- 
        Save sebersole/5579237 to your computer and use it in GitHub Desktop. 
    Alternative getAppropriateUniqueKeyLoader impl
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private EntityLoader getAppropriateUniqueKeyLoader(String propertyName, SessionImplementor session) { | |
| final boolean useStaticLoader = !session.getLoadQueryInfluencers().hasEnabledFilters() | |
| && !session.getLoadQueryInfluencers().hasEnabledFetchProfiles() | |
| //ugly little workaround for fact that createUniqueKeyLoaders() does not handle component properties | |
| && propertyName.indexOf( '.' ) < 0; | |
| if ( useStaticLoader ) { | |
| EntityLoader loader = (EntityLoader) uniqueKeyLoaders.get( propertyName ); | |
| if ( loader == null ) { | |
| if ( propertyName.equals( entityMetamodel.getIdentifierProperty().getName() ) ) { | |
| loader = (EntityLoader) loaders.get( LockMode.READ ); | |
| uniqueKeyLoaders.put( propertyName, loader ); | |
| } | |
| else { | |
| throw new MappingException( "Property [" + propertyName + "] not known to be unique" ); | |
| } | |
| } | |
| return loader; | |
| } | |
| else { | |
| return createUniqueKeyLoader( | |
| propertyMapping.toType( propertyName ), | |
| propertyMapping.toColumns( propertyName ), | |
| session.getLoadQueryInfluencers() | |
| ); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment