2016-03-08 48 views
0

我有一個顯示Liferay內容的自定義門戶組件,我必須能夠對這些內容進行評分。 我恢復此內容的收視信息使用LIferay評估內容API

RatingsStats currentRate = RatingsStatsLocalServiceUtil.getStats(JournalArticle.class.getName(), 
        article.getResourcePrimKey()); 

,但瘋狂的事情是,當我更新此表中的任何領域一樣currentRate.getTotalEntries(),該數據沒有更新。

我附上了完整的方法和日誌。

article = JournalArticleLocalServiceUtil.getArticle(primKey);   
RatingsStats currentRate = RatingsStatsLocalServiceUtil.getStats(JournalArticle.class.getName(), 
        article.getResourcePrimKey()); 
LOG.debug("ratingStats entrada a editar: " + currentRate.getStatsId()); 
LOG.debug("currentRate.getTotalEntries() BEFORE: " + currentRate.getTotalEntries()); 
currentRate.setTotalEntries(currentRate.getTotalEntries()+1); 
LOG.debug("currentRate.getTotalEntries() AFTER: " + currentRate.getTotalEntries()); 

的LOG如下:

11:35:18,634 DEBUG [AgregadoresContenidosController:262] ratingStats entrada a editar: 110551 
11:35:18,634 DEBUG [AgregadoresContenidosController:263] currentRate.getTotalEntries() BEFORE: 0 
11:35:18,635 DEBUG [AgregadoresContenidosController:265] currentRate.getTotalEntries() AFTER: 1 

每次我getTotalEntries,該值時,不更新 '0'。

有什麼想法?

在此先感謝

回答

0

我想對數據庫更新將與方法的設置自動地,但是我錯了。

爲了在DDBB中進行更新,需要以下行。

RatingsStatsLocalServiceUtil.updateRatingsStats(currentRate); 

疑問解決:)