The nature of the magnetic and structural phase transitions in BaFe$_{2}$As$_{2}$