However, objects are in general rather resistant to energy damage. Sonic does full damage to objects, cold does 1/4 damage, and acid, fire and electricity do 1/2 damage. Then you apply the object's hardness on top of that (and remember that hardness and hp are increased by magical enhancement bonuses).
So, if you toss a Fireball at a longsword +2 at 8th level, you first roll the 8d6 damage and get, say, 28 (pretty average). Then you halve that to get 14. Then apply the sword's hardness of 12 (base 10, +2 for a +2 sword), and the sword only takes 2 points of damage.