A character dreaming in the story in order to advance the plot is one thing, and that’s perfectly fine. But to have the protagonist wake up from a dream, especially a bad one, and find out that he or she did not actually live what has happened in the story is a cop out on the writer’s part, and in turn cheats the reader/audience of a feeling of a proper story resolution.
“It was just a dream” is a writer’s cop out because it shows that the writer doesn’t know how to properly tie up the story, or is probably uncomfortable doing so. And in turn, that cheats the reader/audience because the reader/audience has, through the story, created a strong bond with the story and the characters. So apparently the writer originally worked hard to build that rapport between the reader/audience and the characters through plotting, setting and character. That story has become a reality to the reader/audience, even in fantasy and sci-fi stories like “Avatar” and “Star Wars”, where whole different worlds far away from earth are created. So to say that an entire story was “just a dream” shatters that reality for the reader/audience.