He was the peloton leader of the Olten cadet military group.
In 1844 , after studying sciences and law, Hammer settled in Solothurn as a lawyer and a notary, but he wroked in Berlin, Zurich and Geneve too.
Elected president of the district court and 1856-68 as cantonal councillor of Solothurn, Hammer was soon regarded as leader of the old liberals and the opposition against the radical-liberal regiment of the landaman Joseph Wilhelm Viktor Vigier von Steinbrugg. In the face of pure party interests, however, he shifted more to his military interests.
General Henri Dufour had already personally distinguished him in the Sonderbund campaign, and the General Staff officer Hammer was promoted to Major in 1858 and Supreme in 1862.
In 1861-68 he was chief instructor (chief of arms) of the artillery and afterwards until 1875 Switzerland envoy in Berlin.
H.'s reputation as an outstanding lawyer, military and diplomat paved the way for him into the Federal Council. He proved his worth in the reorganisation of the federal finances and the reorganisation of the previously unimportant Finance Department, in the question of the alcohol and banknote monopoly, in customs tariff negotiations and in the settlement of the Wohlgemuth affair. During his term of office, he also introduced the military duty substitute tax, created the Banknote Act and revised the Coinage Act. Moreover, H., who was intent on compensation, played an important mediating role behind the scenes in the settlement of the Kulturkampf.
After his resignation in 1890, Hammer served on the National Council for the Liberals until 1896. He owed this unusual career to his good health and financial and administrative skills. He also acted as the leading member of the Gotthard Railway's Board of Directors.
He died in 1907, highly respected
During his time in office he held the following departments:
- Department of Finance (1876–1878)
- Political Department as President of the Confederation (1879)
- Department of Finance (1880–1890)
He was President of the Confederation twice, in 1879 and 1889.
The portrait of Hammer was painted in 1889 by the Swiss-born American artist Adolfo Müller-Ury (1862–1947) and is signed Muller d'Uri. It was reproduced on the cover of the dust-wrapper and as the frontispiece of Eduard Fischer's biography 'Bundesrat Bernhard Hammer und Seine Zeit', published in Solothurn in 1970. Its present whereabouts (2007) is unknown.