Source: Flickr user

It's been proved time and again that long-term thinking outperforms short-term trading. With that in mind, we asked five different Motley Fool contributors to share their favorite stock ideas for the long haul. Read on to learn which stocks these industry watchers believe could have what it takes to earn a spot in your forever portfolio.

Matt DiLallo: When I think about a forever stock, two key criteria come to mind. First, the company needs to sell a product or service into a long-term uptrend of demand. Second, the company needs to be built to last, meaning it has a history of generating a lot of cash flow and a strong balance sheet. One company that really fits this mold is ExxonMobil (XOM 2.63%).

While renewables get a lot of press today, hydrocarbons aren't going to be replaced anytime soon. In fact, daily demand for oil is expected to grow by 1% per year, or about 1 million barrels, for decades to come, because emerging-market economies have a voracious appetite for energy, which is expected to fuel growing demand for oil and gas.

However, oil and gas prices tend to by highly cyclical, and today prices are clearly on the downswing. This situation has affected weaker producers, who are struggling under a weight of debt now that oil-fueled cash flows have fallen. Exxon, on the other hand, isn't plagued by these issues because it has one of the best balance sheets -- and not just in the energy sector: Its AAA-rated credit is one of the best in the world. Further, thanks to its scale and access to lower-cost oil, Exxon continues to generate billions of dollars in free cash flow each quarter despite weak prices. 

Suffice it to say that Exxon is built to last.

With decades of growth left in the tank and a fortress-like balance sheet, Exxon really is a foundational stock that an investor could buy and forget.

Todd Campbell: There's no longer time horizon than forever, and there's no guarantee that any stock will have the staying power to positively affect portfolios for generations, but if I had to pick one company that might be forever-worthy, it would be Johnson & Johnson (JNJ 1.40%).

Johnson & Johnson makes its money selling commonly used over-the-counter brands such as Band-Aid and Listerine, top-selling pharmaceuticals, and medical devices. It sells so much of this stuff that its third-quarter revenue totaled more than $17 billion.

Importantly, Johnson & Johnson does a good job turning its tens of billions of dollars in annualized sales into profit. Last quarter, Johnson & Johnson's earnings exceeded $3 billion.

JNJ Chart

JNJ data by YCharts

The company's top- and bottom-line performance is even more compelling when we recognize that its long-term growth has come in spite of competitive threats and economic downturns.

Johnson & Johnson's uncanny knack for discovering and commercializing new products, medicines, and medical technology has led to a steady-Eddy reputation for investor-friendly dividends that's allowed it to outperform the market during inevitable corrections and bear markets. Overall, Johnson & Johnson's staying power and ability to thrive over time makes it a great option for long-minded investors.

Tim Green: Forever is a long time, and any company that will be part of your investment portfolio for the long haul needs to have two things: a sustainable competitive advantage, and a long track record of success. Corning (GLW -1.07%), a leading manufacturer of glass and ceramics, fits the bill.

Today, Corning is best known for making the glass used in LCD screens, as well as for Gorilla Glass, the scratch-resistant glass that's now been used in 4.5 billion devices. In its early days, Corning manufactured glass encasements for Thomas Edison's incandescent lamp, and over its 164-year history, the company has transformed itself again and again. From creating Pyrex in 1913 to producing the glass used in the mirror of the Hubble telescope, Corning's success has been driven by constant innovation.

Corning may look like a very different company 20 years from now, but its vast patent portfolio and its long history of innovation give the company a competitive advantage. The ride is unlikely to be smooth for investors; Corning's earnings and stock price have been volatile over the past decade, in part because of Corning's dependence on sales of LCD screens. But Corning has demonstrated an ability to adapt in the past, and for investors with a holding period of forever, that track record makes the company a great choice.

Daniel Miller: When you're looking at stocks you could buy and hold forever, the business would have to possess a long track record of returning value to shareholders, have some protection in the event of an economic slowdown, and offer a long-term growth story. Boeing (BA -0.14%) meets all the criteria and is my pick for a stock to buy and hold forever.

Currently, Boeing's dividend is at $0.91 per share, which is more than double what it paid out in 2012 and roughly triple what it was in 2006. Also, about a year ago, CEO Jim McNerney announced the company's authorization to boost its share-repurchase program to $12 billion -- the largest in its history.

BA Dividend Chart
BA Dividend data by YCharts

To help long-term investors sleep at night in the event of an economic slowdown, Boeing has a total backlog of $485 billion. Further, 5,700 commercial airplane orders make up $426 billion of that backlog total, which is between six and seven years' worth of annual revenue for its healthy commercial airplane business.

Boeing's long-term growth is a global story, and in late August, Boeing increased its forecast for China's aircraft demand despite the volatility in China's financial market -- which is a great sign for investors. The company estimates that China's commercial airplane fleet will nearly triple over the next two decades. Further, it estimates that there will be demand for more than 38,000 new commercial airplanes over the next two decades, valued at about $5.6 trillion. 

Steve Symington: Every time I purchase a stock, it's with the intention of buying and holding for the long term. But if there's one single business I'm confident will remain a part of my portfolio indefinitely, it's specialty insurer and financial holding company Markel Corporation (MKL 0.75%)

That's not to say Markel is a screaming buy right now. Shares are up more than 30% year to date as of this writing, and they trade at a somewhat steeper-than-usual price-to-book value just shy of 1.7 -- well above the five-year average price-to-book ratio of roughly 1.25.

But it's also not hard to argue that it's a well-deserved premium for this so-called "mini-Berkshire Hathaway." Similar to the company Warren Buffett built, Markel employs a veritable trifecta of businesses to consistently generate and compound shareholder value: first, an insurance business that demonstrates consistently disciplined, profitable underwriting; second, a long-term-oriented investment operation with renowned value investor Tom Gayner at the helm; and third, an ever-growing diversified group of acquired non-insurance businesses under the wing of Gayner and Markel Ventures. 

And of course, it also helps that Markel's executive bonus compensation is tied directly to five-year compound average growth in book value per share. This means that the interests of Markel management are both aligned with those of shareholders, and overwhelmingly in favor of creating shareholder value over long periods of time.

In the end, as long as Markel continues implementing this model and compounding its returns, I intend to continue building and holding my position in this steady performer for the rest of my life.