As a symbol of something to be feared, as well as tamed and used, the meaning of bees in dreams can be ambivalent.
To be stung by a bee is a warning of the possibility of hurt. Being attacked by a swarm indicates that we are creating a situation which may become uncontrollable.
The beehive is said to represent an ordered community and, therefore, the ability to absorb chaos. You might also like to consult the entry for hive.