The energy has to come from somewhere, but it doesn't have to come from electricity (every conversion means energy is lost, and a light -> electricity -> water conversion is potentially less efficient than a more direct conversion).
Hydrosol-2 (see http://en.wikipedia.org/wiki/Hydrosol-2) is an example of solar hydrogen production with no electric current intermediate - it involves high temperatures, so I'm not sure how much energy is lost maintaining that temperature compared to captured producing hydrogen, but it could theoretically be more efficient.