But the prophet Nathan tells David, from the Lord, that this is not to be and that David's son (clearly meaning Solomon) will build a temple for God.
What's literarily exciting is the way that the entire chapter plays with the word "house." Verse 11 says, "Also the LORD telleth thee that he will make thee an house," followed by prophecies that are partly of Solomon and partly of the continuation of David's line and the establishment of the kingship in David's lineage forever. (Hence the excuse for the author of Hebrews to take a portion of vs. 14 to be fulfilled in Jesus Christ, despite the fact that its first fulfillment is clearly intended to be in Solomon.)
When David replies, he goes in and sits "before the Lord" (in the tabernacle, perhaps?) and says, "Who am I, O Lord God? And what is my house, that thou hast brought me hitherto?" (vs. 18) David's entire prayer is a kind of poem. Here is a further excerpt:
And now, O Lord God, the word that thou hast spoken concerning thy servant, and concerning his house, establish it for ever, and do as thou hast said. And let thy name be magnified for ever, saying, The Lord of hosts is the God over Israel, and let the house of thy servant David be established before thee. For thou, O Lord of hosts, God of Israel, hast revealed to thy servant, saying, I will build thee an house. Therefore hath thy servant found in his heart to pray this prayer unto thee. (vss. 25-27)So David tells God that he wants to build God a house, and God tells David, "No, I'm the one doing the building around here. I will build you a house," using "house" in the sense of "lineage" or "descendants." And David, the poet, is awed and delighted by God's promises and by God's use of wordplay in making those promises and turns around and makes a masterpiece of a prayer to praise God.
It's important for us Gentiles to realize how intensely Jewish all of this is. The Jewish delight in wordplay in the Old Testament is very strong. (Another example is the fact that "Samuel" means "God hears" and that when God speaks to the boy Samuel in the night in the tabernacle, the old priest Eli tells Samuel to say to God, "Speak, Lord, for your servant hears." God heard--which includes responded to--Samuel's mother and sent her a son. Her son must, in turn, hear the Lord.)
This is relevant to the whole notion of fulfillment and prophecy. It's very easy for us literal-minded Anglo-Saxons to feel slightly frustrated at such concepts as layers of meaning, double fulfillments, and the like. And impatience with highly, shall we say, creative Scriptural interpretations, interpretations that have an excessive ratio of imagination to justification, is understandable. But at the same time, part of understanding the meaning of Scripture, both the Old Testament and the New Testament, is understanding that symbolism, typology, and even what one might call puns, including historical puns, are part of the meaning. I may have more to say about this another time, as I've had an interesting discussion of the matter of Biblical prophecy and "reading the Old Testament in light of the New Testament" with a Facebook friend lately. For the nonce, just enjoy 2 Samuel 7.