What happens if I change the polarity of the battery?
Ideal dielectrics = insulators such as capacitors and batteries have no effective series resistance (ESR).

Ideal dielectrics do not exist.

All dielectrics have ESR which follow the losses defined by Ohm's Law and thermal resistance that determines the temperature rise in the dielectric.

When reversing the charge on a polarized dielectric Capacitor ( Cap.), the insulation may break down and destroy the part, especially if the circuit impedance is as low as the ESR  of the cap.  If the reverse voltage is > 5% of the forward rating the risk of damage increases exponentially, although in current limited circuits some polarized caps can withstand -10% of Vmax for peak AC audio signals with some forward DC bias voltage. 

When reversing a non-polarized capacitor the energy previously stored and not decayed by self-leakage resistance \$E=0.5CV^2\$ which is the same quantity of energy stored after apply the same voltage reverse.

However to invert these charges, the cap. will conduct \$I_{peak}=\dfrac{2|V|}{ESR}\$ in peak current with an exponential decay  of \$\tau= ESR*C\$ [s] for current as the exponential reversal of voltage.  The energy dissipated during thi discharge/charge process is from the ESR current*voltage power  losses as explained in your textbook. 

We say power dissipation=+ve is a positive value and generated power=-ve has a negative polarity, yet the energy product of the power P(t) and time integral is just  an  energy transfer ( as it is neither created or destroyed).  So as the energy stored is the same quantity as before but just as if the leads were reversed yet power had to be generated  by some supply and lost in the cap. during the process.

NPO/COG ceramix are low density ceramics are known to have low ESR as well as plastic film caps in the milliohm range thus will conduct very high current.

Batteries are like massive capacitors due to the high relative dielectric constant, , Dk ( or \$\epsilon _r\$), so a similar heat loss power process occurs going from one polarized  voltage level to a higher state of charge (SOC) voltage to store more energy.