Basking in the effusive warmth of the official welcome he had received in Beijing, José Luis Rodríguez Zapatero, the Spanish prime minister, left the Chinese capital last week convinced he had secured the promise of billions of dollars of investment in Spain’s struggling savings banks.

Had not Wen Jiabao, China’s premier, said that Spain was “China’s best friend in Europe”? Had he not also said that “two countries know true friendship in adversity, as the greenness of the pine tree is revealed in the harshest depths of the winter”? Westerners love a good Chinese proverb.

Had not Mr Zapatero been equally fulsome, reciprocating the compliment by declaring that “China is Spain’s best friend” and stifling the urge to complain in public about human rights abuses or the arrest of the dissident artist Ai Weiwei?

And had not Xie Ping, a senior official of the China Investment Corp (CIC), a big sovereign wealth fund, spoken to Mr Zapatero of the €9 billion ($12.9 billion) available to spend on restructured banks and Spanish sovereign debt?

That, at least, was what euphoric Spanish officials breathlessly told their national media.

But in the cold light of the next day, the CIC denied any concrete plan to invest, and Madrid had to confess to “an error of communication”. It turned out that the CIC would never have considered such a big investment and that Mr Xie was not quite as important in the fund as the Spanish believed.

There are lessons for both sides in this embarrassing episode.

Since the depths of the global financial crisis in 2008, western governments and bankers have abased themselves before newly wealthy “emerging” powers in search of cash to shore up financial institutions and, in the case of weaker eurozone economies such as Portugal and Spain, in the hunt for buyers for their sovereign bonds.

Spain’s government, for example, says it has previously secured promises from Qatar and Abu Dhabi, for €300 million and €150 million respectively, to invest in Spanish savings banks as they seek market listings, although the promises are vague and the amounts small when set against new capital needs of between €15 billion and €120 billion for the sector.

Before flying off to Singapore to pass round the hat, Mr Zapatero also suggested to Mr Wen that China should buy a stake in the airports authority Spain plans to privatize.

Yet every western leader should be aware of the awkward history of such investments. Some have been motivated by geopolitics and others by financial considerations. But investment funds have sometimes suffered painful losses after hurriedly agreeing to buy stakes in western banks since 2008.

Temasek, the Singapore state investment agency, lost an estimated $2.3 billion-$4.6 billion when it sold a Bank of America stake in 2009, while GIC (Government of Singapore Investment Corporation) was last year left nursing an unrealized loss on a big investment in UBS convertible bonds.

From now on, it is unlikely that friendship will have anything to do with it. If Spanish savings banks clean up their act, then private investors and sovereign wealth funds will invest in them to make a profit, regardless of the government relations between Spain and China, Singapore or Qatar.

The same is true of sovereign debt, a market in which China is already a substantial player. If Madrid cuts its budget deficit and makes Spain’s economy more competitive, then investors of all kinds will buy Spanish bonds. If not, even the friendliest Chinese or Qatari fund manager is likely to steer clear, regardless of official expressions of bonhomie.

Nations such as China – whose surplus wealth makes them the dominant partner in most bilateral financial relationships – should learn to refrain from telling over-eager visitors what they want to hear, for fear of being misinterpreted and causing disappointment.

Spaniards must have winced when Li Keqiang, Mr Wen’s likely successor as premier, told them with magnificent condescension: “Spain is a country with great potential.”

If Spain is requesting foreign aid, and if China wants to give it, then they should say so. But if the topic is investment, both sides must accept that money will flow to where it can earn a good return. The rest is empty politics.