The Jataka, Vol. II, tr. by W.H.D. Rouse, , at sacred-texts.com
"Once with the great king Assaka," etc.--This story the Master told whilst staying in Jetavana, about some one who was distracted by the recollection of a former wife. He asked the Brother whether he were really lovesick. The man said, Yes. "Whom are you in love with?" the Master continued. "My late wife," was the reply. Then the Master said, "Not this once only, Brother, have you been full of desire for this woman; in olden days her love brought you to great misery." And he told a story.
Once upon a time, there was a king Assaka reigning in Potali, which is a city of the kingdom of Kāsi. His queen consort, named Ubbarī, was very dear to him; she was charming, and graceful, and beautiful passing the beauty of women, though not so fair as a goddess. She died: and at her death the king was plunged in grief, and became sad and miserable. He had the body laid in a coffin, and embalmed with oil and ointment, and laid beneath the bed; and there he lay without food, weeping and wailing.  In vain did his parents and kinsfolk, friends and courtiers, priests and laymen, bid him not to grieve, since all things pass away; they could not move him. As he lay in sorrow, seven days passed by.
Now the Bodhisatta was at that time an ascetic, who had gained the Five Supernatural Faculties and the Eight Attainments; he dwelt at the foot of Himalaya. He was possessed of perfect supernatural insight, and as he looked round India with his heavenly vision, he saw this king lamenting, and straightway resolved to help him. By his miraculous power he rose in the air, and alighted in the king's park, and sat down on the ceremonial stone, like a golden image.
A young brahmin of the city of Potali entered the park, and seeing the Bodhisatta, he greeted him and sat down. The Bodhisatta began to talk pleasantly with him. "Is the king a just ruler?" he asked.
"Yes, Sir, the king is just." replied the youth; "but his queen is just dead; he has laid her body in a coffin, and lies down lamenting her; and to-day is the seventh day since he began.--Why do you not free the king from this great grief? Virtuous beings like you ought to overcome the king's sorrow."
"I do not know the king, young man," said the Bodhisatta; "but if he were to come and ask me, I would tell him the place where she has now come into the flesh again, and make her speak herself."
"Then, holy Sir, stay here until I bring the king to you," said the
youth. The Bodhisatta agreed, and he hastened into the king's presence, and told him about it. "You should visit this being with the divine insight!" he told the king.
The king was overjoyed, at the thought of seeing Ubbarī; and he entered his chariot and drove to the place. Greeting the Bodhisatta, he sat down on one side, and asked, "Is it true, as I am told, that you know where my queen has come into being again?"
"Yes, I do, my lord king," replied he.
Then the king asked where it was.
The Bodhisatta replied, "O king, she was intoxicated with her beauty, and so fell into negligence and did not do fair and virtuous acts; so now she has become a little dung-worm in this very park." 
"I don't believe it!" said the king.
"Then I will show her to you, and make her speak," answered the Bodhisatta.
"Please make her speak!" said the king.
The Bodhisatta commanded--"Let the two that are busy rolling a lump of cow-dung, come forth before the king:" and by his power he made them do it, and they came. The Bodhisatta pointed one out to the king: "There is your queen Ubbarī, O king! she has just come out of this lump, following her husband the dung-worm. Look and see."
"What! my queen Ubbarī a dung-worm? I don't believe it!" cried the king.
I will make her speak, O king!"
"Pray make her speak, holy Sir!" said he.
The Bodhisatta by his power gave her speech. "Ubbarī!" said he.
"What is it, holy Sir?" she asked, in a human voice.
"What was your name in your former character?" the Bodhisatta asked her.
"My name was Ubbarī, Sir," she replied, "the consort of king Assaka."
"Tell me," the Bodhisatta went on, "which do you love best now--king Assaka, or this dung-worm?"
"O Sir, that was my former birth," said she. "Then I lived with him in this park, enjoying shape and sound, scent, savour and touch; but now that my memory is confused by rebirth, what is he? Why, now I would kill king Assaka, and would smear the feet of my husband the dung-worm with the blood flowing from his throat!" and in the midst of the king's company, she uttered these verses in a human voice:
"But now new sorrows and new joys have made the old ones flee,
And dearer far than Assaka my Worm is now to me."
 When king Assaka heard this, he repented on the spot; and at once he caused the queen's body to be removed and washed his head. He saluted the Bodhisatta, and went back into the city; where he married another queen, and ruled in righteousness. And the Bodhisatta, having instructed the king, and set him free from sorrow, returned again to the Himalayas.
When the Master had ended this discourse, he declared the Truths and identified the Birth:--at the conclusion of the Truths, the lovesick Brother reached the Fruit of the First Path:--"Your late wife was Ubbarī; you, the lovesick Brother, were king Assaka; Sāriputta was the young brahmin; and the anchorite was I myself."