2 of 2 Added dissenting opinion

The Gemora (Gitin 57b) states that Hashem showed Dovid Hamelech a prophecy of the destruction of the two temples and he composed Tehillim Chapter 137.

However the Ibn Ezra (in his introduction to his commentary on Tehillim) writes that some say it was composed at the time of the Babylonian Exile.