public static boolean updateOrderStatus(int orderId, int statusCode)
			throws HibernateException {
		boolean isUpdateOrderStatusSuccessful = false;
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		try {
			// Begin unit of work
			session.beginTransaction();

			Calendar calendar = new GregorianCalendar();

			// Check the old available orders for per user
			String hql = "select o from OrderInfo as o where o.orderId="
					+ orderId + " and DAYOFMONTH(o.createDate)="
					+ calendar.get(Calendar.DAY_OF_MONTH)
					+ " and MONTH(o.createDate)="
					+ (calendar.get(Calendar.MONTH) + 1)
					+ " and YEAR(o.createDate)=" + calendar.get(Calendar.YEAR);

			Query query = session.createQuery(hql);

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

			if (orders.size() > 0) {
				OrderInfo orderInfoEntity = orders.get(0);
				if (orderInfoEntity.getOrderStatus() != statusCode) {
					orderInfoEntity.setOrderStatus(statusCode);
					session.save(orderInfoEntity);
				}
				isUpdateOrderStatusSuccessful = true;
			}

			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 isUpdateOrderStatusSuccessful;

	}