If this is about a multi-apartment building, the landlord is unlikely to give notice because the more apartements are occupied, and the longer the better, the more attractive the building will be to the potential buyer.
However the buyer may try to increase the rent later on, which OP may also be able to contest.
As always in such cases as well as in general:
You're strongly recommended to join the
Mieterverband.