EntityInstance entityInstance = instanceCache.get( identity );
if( entityInstance == null )
{ // Not yet in cache
// Check if this is a root UoW, or if no parent UoW knows about this entity
EntityState entityState = null;
EntityModel model = null;
ModuleInstance module = null;
// Figure out what EntityStore to use
for( ModelModule<EntityModel> potentialModule : potentialModels )
{
EntityStore store = potentialModule.module().entityStore();
EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store, potentialModule.module() );
try
{
entityState = storeUow.getEntityState( identity );
}
catch( EntityNotFoundException e )
{
continue;
}
// Get the selected model
model = (EntityModel) entityState.entityDescriptor();
module = potentialModule.module();
}
// Check if model was found
if( model == null )