2016-06-08 67 views
1

最近,我打算通過hibernate.I的一篇文章看到了這個請賜教這個是什麼收益之間的差異本VS回報新類()

public Criteria createCriteria(String associationPath, String alias, int joinType) { 
    return new Subcriteria(this, associationPath, alias, joinType);//return new object 
} 


public Criteria createAlias(String associationPath, String alias, int joinType) { 
    new Subcriteria(this, associationPath, alias, joinType); 
    return this;//return this 
} 
+0

你有鏈接到文章? – Thilo

+0

我有一點答案,但沒有正確理解。 http://stackoverflow.com/questions/18062286/difference-between-creatcriteria-and-createalias – ThinkTank

回答

2

第一個例子將返回一個新的實例類型Subcriteria。第二個將返回當前實例。在java here中查看關於此關鍵字的討論和here

所以區別很簡單。

  1. 現有(當前)

您在評論中提供的鏈接清楚地回答了這個問題。再看一遍。

+1

感謝您的鏈接@nabin – ThinkTank

相關問題