Yeah, ive read that it can be stressful for the hamster but I know many people who have a dog or a cat who also have a hamster, and their hamster is completely fine!
my dog and cat are also never in my room, and my door is always shut. Even those rare times my dog gets into my room, hes in there for not even 5 seconds