Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDao.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDao.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDao.java (revision ) @@ -49,4 +49,15 @@ getSession().delete(branch); return true; } + + /** + * {@inheritDoc} + */ + public int getTopicInBranchCount(Branch branch) { + return ((Number) getSession().getNamedQuery("getTopcInBranchCount") + .setCacheable(true) + .setEntity("branch", branch) + .uniqueResult()) + .intValue(); -} \ No newline at end of file + } +} \ No newline at end of file Index: jcommune/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java =================================================================== --- jcommune/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-controller/src/test/java/org/jtalks/jcommune/web/controller/BranchControllerTest.java (revision ) @@ -83,6 +83,4 @@ verify(topicService).getTopicRangeInBranch(branchId, startIndex, pageSize); verify(topicService).getTopicsInBranchCount(branchId); } - - } Index: jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Topic.hbm.xml =================================================================== --- jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Topic.hbm.xml (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Topic.hbm.xml (revision ) @@ -37,5 +37,8 @@ WHERE topic.branch_id = :branchId ORDER BY post.post_date DESC]]> + + + Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDao.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDao.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDao.java (revision ) @@ -74,4 +74,16 @@ .setString(0, email) .uniqueResult()).intValue() != 0; } + + /** + * {@inheritDoc} + */ + @Override + public int getCountPostOfUser(User userCreated){ + return ((Number) getSession().getNamedQuery("getCountPostOfUser") + .setCacheable(true) + .setEntity("userCreated",userCreated) + .uniqueResult()) + .intValue(); -} + } +} Index: jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Post.hbm.xml =================================================================== --- jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Post.hbm.xml (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/resources/org/jtalks/jcommune/model/entity/Post.hbm.xml (revision ) @@ -20,4 +20,8 @@ + + + + Index: jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/BranchService.java =================================================================== --- jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/BranchService.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/BranchService.java (revision ) @@ -34,4 +34,11 @@ * @return - list of persistence objects T. */ List getAll(); + + /** + * Get count topics in branch from database + * @param branch branch + * @return count count + */ + int getTopicInBranchCount(Branch branch); } \ No newline at end of file Index: jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties =================================================================== --- jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_en.properties (revision ) @@ -42,6 +42,7 @@ label.currentPassword=Enter your current password label.incorrectCurrentPassword=Password does not match to the current password label.email=Email +label.postcount=Post count #labels for pm label.pm=Private Messages label.pm_title = Private Messages Index: jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/UserService.java =================================================================== --- jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/UserService.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/UserService.java (revision ) @@ -84,4 +84,11 @@ */ User editUserProfile(String email, String firstName, String lastName, String currentPassword, String newPassword) throws DuplicateEmailException, WrongPasswordException; + + /** + * Get count posts this user from database + * @param userCreated user created + * @return count count + */ + int getCountPostOfUser(User userCreated); } Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/BranchDao.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/BranchDao.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/BranchDao.java (revision ) @@ -34,4 +34,12 @@ * @return list of branches */ List getAll(); + + /** + * Get topics count in branch. + * + * @param branch branch + * @return topics count + */ + int getTopicInBranchCount(Branch branch); } \ No newline at end of file Index: jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDaoTest.java =================================================================== --- jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDaoTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/UserHibernateDaoTest.java (revision ) @@ -19,7 +19,11 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; +import org.jtalks.jcommune.model.dao.PostDao; import org.jtalks.jcommune.model.dao.UserDao; +import org.jtalks.jcommune.model.entity.Branch; +import org.jtalks.jcommune.model.entity.Post; +import org.jtalks.jcommune.model.entity.Topic; import org.jtalks.jcommune.model.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; @@ -48,14 +52,17 @@ public class UserHibernateDaoTest extends AbstractTransactionalTestNGSpringContextTests { @Autowired private UserDao dao; + private PostDao daoP; @Autowired private SessionFactory sessionFactory; private Session session; + private User user; @BeforeMethod public void setUp() throws Exception { session = sessionFactory.getCurrentSession(); ObjectsFactory.setSession(session); + user = ObjectsFactory.getDefaultUser(); } /*===== Common methods =====*/ @@ -217,7 +224,75 @@ assertFalse(result, "User exist"); } + @Test + public void testDaoUserPostCountCreateNewPost() { + Post post = Post.createNewPost(user,""); + dao.saveOrUpdate(user); + session.save(post); + + int result = dao.getCountPostOfUser(user); + assertEquals(result, 1); + } + + @Test + public void testDaoUserPostCountDeleteBranch(){ + Post post1 = Post.createNewPost(user,""); + Topic topic = new Topic(user,""); + Branch branch = ObjectsFactory.getDefaultBranch(); + + topic.addPost(post1); + branch.addTopic(topic); + + dao.saveOrUpdate(user); + session.save(branch); + + int result = dao.getCountPostOfUser(user); + assertEquals(result,1); + + session.delete(branch); + + result = dao.getCountPostOfUser(user); + assertEquals(result,0); + } + + @Test + public void testDaoUserPostCountDeleteTopic(){ + Post post1 = Post.createNewPost(user,""); + Topic topic = new Topic(user,""); + Branch branch = ObjectsFactory.getDefaultBranch(); + + topic.addPost(post1); + branch.addTopic(topic); + + dao.saveOrUpdate(user); + session.save(branch); + + int result = dao.getCountPostOfUser(user); + assertEquals(result,1); + + branch.deleteTopic(topic); + + result = dao.getCountPostOfUser(user); + assertEquals(result,0); + } + + @Test + public void testDaoUserPostCountRemovePost(){ + Post post = Post.createNewPost(user,""); + + dao.saveOrUpdate(user); + session.save(post); + + int result = dao.getCountPostOfUser(user); + assertEquals(result,1); + + session.delete(post); + + result = dao.getCountPostOfUser(user); + assertEquals(result, 0); + } + private int getCount() { return ((Number) session.createQuery("select count(*) from User").uniqueResult()).intValue(); } -} +} \ No newline at end of file Index: jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalTopicServiceTest.java =================================================================== --- jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalTopicServiceTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalTopicServiceTest.java (revision ) @@ -141,11 +141,11 @@ Topic createdTopic = topicService.createTopic(TOPIC_TITLE, ANSWER_BODY, BRANCH_ID); + Post createdPost = createdTopic.getFirstPost(); assertEquals(createdTopic.getTitle(), TOPIC_TITLE); assertEquals(createdTopic.getTopicStarter(), author); assertEquals(createdTopic.getBranch(), branch); - assertEquals(branch.topicCount(), 1, "Topic not added to branch"); assertEquals(createdPost.getUserCreated(), author); assertEquals(createdPost.getPostContent(), ANSWER_BODY); verify(securityService).getCurrentUser(); @@ -248,7 +248,7 @@ Branch branchFromWhichTopicDeleted = topicService.deleteTopic(TOPIC_ID); assertEquals(branchFromWhichTopicDeleted, branch); - assertEquals(branch.topicCount(), 0); + assertEquals(branch.getTopicCount(), 0); verify(branchDao).saveOrUpdate(branch); verify(securityService).deleteFromAcl(Topic.class, TOPIC_ID); } Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/UserDao.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/UserDao.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/dao/UserDao.java (revision ) @@ -65,4 +65,10 @@ * false */ boolean isUserWithEmailExist(String email); + + /** + * @param userCreated user created + * @return count posts of user + */ + int getCountPostOfUser(User userCreated); } Index: jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalBranchService.java =================================================================== --- jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalBranchService.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalBranchService.java (revision ) @@ -46,6 +46,21 @@ */ @Override public List getAll() { - return dao.getAll(); + List list = dao.getAll(); + + for(Branch branch : list) + { + branch.setTopicCount(dao.getTopicInBranchCount(branch)); - } + } + + return list; -} \ No newline at end of file + } + + /** + * {@inheritDoc} + */ + @Override + public int getTopicInBranchCount(Branch branch){ + return dao.getTopicInBranchCount(branch); + } +} \ No newline at end of file Index: jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDaoTest.java =================================================================== --- jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDaoTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/test/java/org/jtalks/jcommune/model/dao/hibernate/BranchHibernateDaoTest.java (revision ) @@ -56,11 +56,13 @@ @Autowired private BranchDao dao; private Session session; + Branch branch; @BeforeMethod public void setUp() throws Exception { session = sessionFactory.getCurrentSession(); ObjectsFactory.setSession(session); + branch = ObjectsFactory.getDefaultBranch(); } /*===== Common methods =====*/ @@ -199,6 +201,18 @@ assertEquals(((Number) session.createQuery("select count(*) from Post").uniqueResult()).intValue(), 0); } + @Test + public void testDaoTopicInBranchCount() { + Topic topic = ObjectsFactory.getDefaultTopic(); + session.save(topic); + branch.addTopic(topic); + session.save(branch); + + int result = dao.getTopicInBranchCount(branch); + + assertEquals(result, 1); + } + private int getBranchCount() { return ((Number) session.createQuery("select count(*) from Branch").uniqueResult()).intValue(); } Index: jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/branchesList.jsp =================================================================== --- jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/branchesList.jsp (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/branchesList.jsp (revision ) @@ -14,6 +14,9 @@ value="${branch.name}"/>
+ + + Index: jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties =================================================================== --- jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-view/src/main/resources/org/jtalks/jcommune/web/view/messages_ru.properties (revision ) @@ -42,6 +42,7 @@ label.currentPassword=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u0430\u0448 \u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u043F\u0430\u0440\u043E\u043B\u044C label.incorrectCurrentPassword=\u041F\u0430\u0440\u043E\u043B\u044C \u043D\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0430\u0435\u0442 \u0441 \u0442\u0435\u043A\u0443\u0449\u0438\u043C \u043F\u0430\u0440\u043E\u043B\u0435\u043C label.email=\u0418\u043C\u0435\u0439\u043B +label.postcount=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043F\u043E\u0441\u0442\u043E\u0432 #labels for pm label.pm=\u041b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f label.pm_title = \u041b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Branch.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Branch.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Branch.java (revision ) @@ -31,6 +31,7 @@ private String name; private String description; + private int topicCount; private List topics = new ArrayList(); /** @@ -103,9 +104,20 @@ } /** - * @return number of topics in branch + * @return count topics in branch */ - public int topicCount() { - return topics.size(); + public int getTopicCount() + { + return this.topicCount; } + + /** + * @param topicCount count topics to set + */ + public void setTopicCount(int topicCount) + { + this.topicCount= topicCount; -} + } + + +} Index: jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java =================================================================== --- jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/UserController.java (revision ) @@ -17,6 +17,7 @@ */ package org.jtalks.jcommune.web.controller; +import org.hibernate.Session; import org.jtalks.jcommune.model.entity.User; import org.jtalks.jcommune.service.SecurityService; import org.jtalks.jcommune.service.UserService; @@ -31,11 +32,7 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import javax.validation.Valid; @@ -54,6 +51,7 @@ private final SecurityService securityService; private final UserService userService; + private Session session; /** * This method turns the trim binder on. Trim bilder Index: jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalUserServiceTest.java =================================================================== --- jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalUserServiceTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalUserServiceTest.java (revision ) @@ -32,10 +32,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import static org.testng.Assert.assertEquals; /** @@ -252,4 +249,14 @@ assertEquals(dateTimeAfter.compareTo(dateTimeBefore), 1, "last login time lesser than before test"); verify(userDao).saveOrUpdate(user); } + + @Test + public void testTransactionUserPostCount() throws NotFoundException { + User user = new User(USERNAME, EMAIL, PASSWORD); + when(userDao.getCountPostOfUser(user)).thenReturn(1); + + assertEquals(userService.getCountPostOfUser(user),1); + + verify(userDao).getCountPostOfUser(user); -} + } +} Index: jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/userDetails.jsp =================================================================== --- jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/userDetails.jsp (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-view/src/main/webapp/WEB-INF/jsp/userDetails.jsp (revision ) @@ -45,8 +45,12 @@ locale="${sessionScope['org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE']}" pattern="dd MMM yyyy HH:mm"/> - -
  • +
  • +
  • + + +
  • +
  • Index: jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalBranchServiceTest.java =================================================================== --- jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalBranchServiceTest.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/test/java/org/jtalks/jcommune/service/transactional/TransactionalBranchServiceTest.java (revision ) @@ -80,4 +80,14 @@ assertEquals(actualBranchList, expectedBranchList); verify(branchDao).getAll(); } + + @Test + public void testTransactionTopicInBranchCount() throws NotFoundException { + Branch branch = new Branch(); + when(branchDao.getTopicInBranchCount(branch)).thenReturn(1); + + assertEquals(branchService.getTopicInBranchCount(branch),1); + + verify(branchDao).getTopicInBranchCount(branch); -} + } +} Index: jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java =================================================================== --- jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-view/jcommune-web-controller/src/main/java/org/jtalks/jcommune/web/controller/BranchController.java (revision ) @@ -59,7 +59,8 @@ /** - * This method handles GET request and produces JSP page with all topic branches + * This method handles GET request and produces JSP page with all topic branches and count + * topics in each branch * * @return {@link ModelAndView} with view name as renderAllBranches */ Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Post.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Post.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/Post.java (revision ) @@ -78,6 +78,15 @@ } /** + * Creates the new instance with the creationDate initialized with current time.*** + * + * @return new Post instance + */ + public static Post createNewPost(User userCreated, String postContent) { + return new Post(userCreated,postContent); + } + + /** * @return the postDate */ public DateTime getCreationDate() { Index: jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalUserService.java =================================================================== --- jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalUserService.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-service/src/main/java/org/jtalks/jcommune/service/transactional/TransactionalUserService.java (revision ) @@ -64,6 +64,7 @@ logger.info(msg); throw new NotFoundException(msg); } + user.setUserPostCount(dao.getCountPostOfUser(user)); return user; } @@ -78,6 +79,7 @@ logger.info(msg); throw new NotFoundException(msg); } + user.setUserPostCount(dao.getCountPostOfUser(user)); return user; } @@ -162,4 +164,12 @@ dao.saveOrUpdate(currentUser); return currentUser; } + + /** + * {@inheritDoc} + */ + @Override + public int getCountPostOfUser(User userCreated) { + return dao.getCountPostOfUser(userCreated); -} + } +} Index: jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/User.java =================================================================== --- jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/User.java (revision 4f741e31a65ad5d339d5bf884acf74d0aeeaee66) +++ jcommune/jcommune-model/src/main/java/org/jtalks/jcommune/model/entity/User.java (revision ) @@ -44,6 +44,7 @@ private DateTime lastLogin; private String role = "ROLE_USER"; private String encodedUsername; + private int userPostCount; /** * Only for hibernate usage. @@ -244,4 +245,18 @@ protected void setEncodedUsername(String encodedUsername) { this.encodedUsername = encodedUsername; } + + /** + * @return count post this user + */ + public int getUserPostCount(){ + return this.userPostCount; -} + } + + /** + * @param userPostCount count posts this user to set + */ + public void setUserPostCount(int userPostCount){ + this.userPostCount = userPostCount; + } +}