/** {@inheritDoc} */ public int getMaximumTreeRank(int productId) { Criteria rootFilter = getRootStoryCriteria(productId); rootFilter.addOrder(Order.desc("treeRank")); rootFilter.setMaxResults(1); Story story = (Story) uniqueResult(rootFilter); if (story == null) { return 0; } else { return story.getTreeRank(); } }