@Transactional(propagation = Propagation.REQUIRED) public void store(User user, Boolean admin) { // TODO Auto-generated method stub try { log.info("in store method admin value" + admin); UserLogins userlogins = new UserLogins(); userlogins.setCsuid(user.getCsuid()); if (admin) { userlogins.setLoginCount(0L); } else { userlogins.setLoginCount(1L); userlogins.setLastLogin(new java.util.Date()); } user.setRegisteredDate(new java.util.Date()); user.setUserLogins(userlogins); userlogins.setUser(user); userDao.store(user); // userDao.storeUserLogins(userlogins); } catch (DataAccessException e) { log.error("In store ", e); throw e; } }
@Override @Transactional(propagation = Propagation.REQUIRED) public void updateUserLogins(Long csuid) { // TODO Auto-generated method stub try { UserLogins ulogin = userDao.getUserLogins(csuid); if (ulogin != null) { Long count = ulogin.getLoginCount(); log.debug("in updateUserLogins,count" + count); count++; ulogin.setLoginCount(count); ulogin.setLastLogin(new Date()); userDao.storeUserLogins(ulogin); } else { User user = userDao.findUser(csuid); ulogin = new UserLogins(); ulogin.setUser(user); ulogin.setLoginCount(1L); ulogin.setLastLogin(new Date()); user.setUserLogins(ulogin); userDao.store(user); } } catch (DataAccessException e) { log.error("in error of update loginS", e); } }