Commentary for Berakhot 9:3
בָּנָה בַיִת חָדָשׁ, וְקָנָה כֵלִים חֲדָשִׁים, אוֹמֵר בָּרוּךְ שֶׁהֶחֱיָנוּ. מְבָרֵךְ עַל הָרָעָה מֵעֵין הַטּוֹבָה, וְעַל הַטּוֹבָה מֵעֵין הָרָעָה. הַצּוֹעֵק לְשֶׁעָבַר, הֲרֵי זוֹ תְּפִלַּת שָׁוְא. כֵּיצַד. הָיְתָה אִשְׁתּוֹ מְעֻבֶּרֶת, וְאָמַר, יְהִי רָצוֹן שֶׁתֵּלֵד אִשְׁתִּי זָכָר, הֲרֵי זוֹ תְּפִלַּת שָׁוְא. הָיָה בָא בַדֶּרֶךְ וְשָׁמַע קוֹל צְוָחָה בָּעִיר, וְאָמַר יְהִי רָצוֹן שֶׁלֹּא יִהְיוּ אֵלּוּ בְּנֵי בֵיתִי, הֲרֵי זוֹ תְּפִלַּת שָׁוְא:
If he built a new house or bought new vessels, he says "shehecheyanu" ("who kept us in life, etc.") [Whether or not he has other vessels of the same kind, he says "shehecheyanu."] One blesses over an evil in which good inheres [The gemara explains: as when one's fields are flooded and he loses this year's crop. Though the soil is saturated and the field made more fertile for the years to come, now, however, it is evil, and he blesses "dayan ha'emeth"], and over a good in which an evil inheres [as when one finds a lost object. Even though it is evil for him, for if the king hears of it, he will be beaten and tortured and the object taken from him, now, however, it is good, and he blesses "hatov vehametiv"]. Crying out over what is past constitutes a vain prayer. [If one prays for what has already taken place, this is a vain prayer, for "what has been has been"], as in one's praying: "May it be Your will that my wife bear a son," when she is already pregnant; or, as in one's returning from a journey and hearing wailing within the city, praying: "May it be Your will that it not be coming from my house."
Bartenura on Mishnah Berakhot
English Explanation of Mishnah Berakhot
One who blesses over the evil as he blesses over the good or over the good as he blesses over evil; one who cries over the past, behold this is a vain prayer.
How so? If his wife was pregnant and he says, “May it be his will that my wife bear a male child,” this is a vain prayer.
If he is coming home from a journey and he hears a cry of distress in the town and says, “May it be his will that this is not be those of my house,” this is a vain prayer.
Section one: This is the familiar blessing “shehecheyanu” which we recite upon eating new foods, receiving new things, at the beginning of holidays and at certain other events.
Section two: This is a difficult clause to explain. Albeck explains that this refers to one who tries to bless over something bad the blessing that he should say for the good, “Blessed be He that is good and grants good.” What he is trying to do is be hopeful that from something bad will come something good. Alternatively, he blesses the blessing for the bad, “Blessed be the true judge” because he fears that something bad will come from the good. These are both vain prayers because after the event has already happened it cannot be changed. Thus these are both specific cases of one who is crying over the past. Prayers are legitimate only if they are recited in anticipation of an event that has not yet occurred. The Rambam explains that this mishnah mandates reciting the blessing over the good for something that is now good even if it might eventually be bad. Similarly, one must recite the blessing over bad for something that is now bad even though it might eventually be good. As in Albeck’s explanation, the focus is on the present and not something that might change in the future.
Sections three and four: These are both examples of “crying over the past.” Once the child’s sex has been determined it cannot change. There is no use in crying out to God in hope that the house that is under distress is not one’s house because whatever house it is has already been determined. Once something has already happened one must be reconciled with one’s fate.