I'm pretty sure they were primarily diesel. The early Uboat type II introduced batteries and the type 20s and onwards (late war) really utilised electricity due to having an engine snorkel, so they could power the batteries directly from diesel while submerged.