The 34-year-old struck the female job centre employee nine times on May 21st this year.
A court in Leipzig sentenced the man, who was long-term unemployed, for attempted murder and grievous bodily harm.
Judge Hans Jagenlauf said the man wanted to kill the woman and had prepared the attack.
Although her injuries were not life threatening, she was only saved by another man who managed to overpower the attacker, the court heard.
The man was arrested afterwards without resistance and admitted attempted murder.
He sat in court showing no emotion as the judgment was read out.
Judge Jagenlauf said the man’s hate for the job centre had grown from making complaints, to attacking another staff member with pepper spray and culminated in the hammer attack.
The court heard that the attacker found it degrading to work in the city’s parks and green spaces.
Although he has a personality disorder, he knew what he was doing, the judge said.
Prosecutors had demanded a life sentence, while the defence argued for no more than nine years in prison.