if( model == null )
{
// Check if state was found
if( entityState == null )
{
throw new NoSuchEntityException( identity, mixinType );
}
else
{
throw new EntityTypeNotFoundException( mixinType.getName() );
}
}
// Create instance
entityInstance = new EntityInstance( uow, module, model, entityState );
instanceCache.put( identity, entityInstance );
}
else
{
// Check if it has been removed
if( entityInstance.status() == EntityStatus.REMOVED )
{
throw new NoSuchEntityException( identity, mixinType );
}
}
return entityInstance.proxy();
}