Another interpretation: "He who tends a fig tree"—this is David, who gave his soul to build the House, as it is written, "Remember, O LORD, for David all his affliction" (Psalms 132:1). "Shall eat its fruit"—for it was called by his name, as it is written, "A Psalm, a song at the dedication of the House, of David" (Psalms 30:1). But did David build it? Did not Solomon build it, as it is written, "And Solomon built the House and finished it"? Rather, because he gave his soul to build the House it was called by his name. And it says, "See to your own house, David" (I Kings 12:16). And so you find with everything that a person gives his soul over to, it is called by his name. Moses gave his soul over to the Torah, and it was called by his name, as it is said, "Remember the Torah of Moses My servant" (Malachi 3:22). But is it not the Torah of God, as it is said, "The Torah of the LORD is perfect" (Psalms 19:8)? Rather, because he gave his soul over to it, it was called by his name. And where do we find that he gave his soul over to the Torah? As it is said, "And he was there with the LORD forty days," and it says, "And I sat on the mountain forty days." You learn from this that because he gave his soul over to the Torah it was called by his name.
David Gave His Soul So the Temple Bore His Name
Yalkut Shimoni on Nach 2:3
דבר אחר נוצר תאנה זה דוד שנתן נפשו לבנות הבית דכתיב זכור ה' לדוד את כל ענותו וגו'. יאכל פריה שנקרא על שמו דכתיב מזמור שיר חנוכת הבית לדוד, וכי דוד בנאו והלא שלמה בנאו דכתיב ויבן שלמה את הבית ויכלהו, אלא לפי שנתן נפשו לבנות הבית נקרא על שמו. ואומר ראה ביתך דוד, וכן אתה מצוא בכל דבר ודבר שאדם נותן נפשו עליו נקרא על שמו, משה נתן נפשו על התורה ונקראת על שמו שנאמר זכרו תורת משה עבדי והלא תורת אלקים היא שנאמר תורת ה' תמימה אלא לפי שנתן נפשו עליה נקראת על שמו, והיכן מצינו שנתן נפשו על התורה שנאמר ויהי שם עם ה' ארבעים יום, ואומר ואשב בהר ארבעים יום וגו' הא למדת לפי שנתן נפשו על התורה נקראת על שמו.