public static boolean updateEventStatus(int eventId, int userId,
			int statusCode) throws HibernateException {
		boolean isUpdateEventStatusSuccessful = false;
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		try {
			// Begin unit of work
			session.beginTransaction();

			// update event status
			String hql = "select e from EventInfo as e where e.ownerId="
					+ userId + " and e.eventId=" + eventId;

			Query query = session.createQuery(hql);

			@SuppressWarnings("unchecked")
			List<EventInfo> list = query.list();

			if (list.size() > 0) {
				// Is owner, then change the event status
				EventInfo eventEntity = list.get(0);
				if (eventEntity.getEventStatus() != statusCode) {
					eventEntity.setEventStatus(statusCode);
					session.save(eventEntity);
				}
				isUpdateEventStatusSuccessful = true;
			}

			// End unit of work
			session.getTransaction().commit();
		} catch (HibernateException hex) {
			logger.error(hex.toString());
			HibernateUtil.getSessionFactory().getCurrentSession()
					.getTransaction().rollback();
		} catch (Exception ex) {
			logger.error(ex.toString());
			HibernateUtil.getSessionFactory().getCurrentSession()
					.getTransaction().rollback();
		}
		return isUpdateEventStatusSuccessful;
	}