Warfare History Network
Yes, this happenned during World War II.
Hitler's Secret Plan to Kill the Royal Navy: Sink Their (Docked) Battleships
Certainly the U-boat went down with all hands, including Prien and seven other members of the original Scapa Flow crew. Indeed, only 15 of the 44 submariners involved in the sinking of the Royal Oak were to survive the war, a testament to the appalling losses the U-boats suffered as a whole. The youngest member of the crew, torpedo mechanic Herbert Herrmann, eventually married a Scottish woman and settled in Dumfriesshire.
World War II had been in progress for six weeks when on the evening of October 12, 1939, the German submarine U-47 surfaced off the Orkney Islands at the northern tip of Scotland. While the officers standing in the conning tower observed the twinkling lights ashore to the west, only the captain, Kapitänleutnant Günther Prien, knew the purpose of their mission. Security surrounding it had been so tight that only now, with the climax approaching, would it be possible to tell his men the reason for so daring a foray into enemy waters.
Following a night of observation, U-47 submerged and withdrew eastward. As it settled on the bottom, the motors were cut and Prien ordered the crew to assemble in the forward mess. The time had come to reveal to these young men—average age of 20—that the following day, they would be entering Scapa Flow.
A Symbolic Mission