public static List<GroupDetailInfo> getGroupDetailByQuery(String keyword)
			throws HibernateException {
		List<GroupDetailInfo> queryResultList = null;
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		try {
			// Begin unit of work
			session.beginTransaction();

			String hqlString = "select distinct g from GroupInfo as g"
					+ " left join g.groupUsers as gu" + " where gu.isOwner=1"
					+ " and (g.groupName like '%" + keyword
					+ "%' or g.groupDescription like '%" + keyword + "%')";

			Query query = session.createQuery(hqlString);

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

			if (list.size() > 0) {
				queryResultList = new ArrayList<GroupDetailInfo>();
				for (int i = 0; i < list.size(); i++) {
					GroupInfo groupInfo = list.get(i);
					GroupDetailInfo groupDetail = new GroupDetailInfo();
					groupDetail.setGroupInfo(groupInfo);

					Set<GroupUserInfo> groupUsers = groupInfo.getGroupUsers();
					int ownerId = groupUsers.iterator().next().getUserId();
					String hqlString2 = "from UserInfo as u where u.userId="
							+ ownerId;
					Query query2 = session.createQuery(hqlString2);
					@SuppressWarnings("unchecked")
					List<UserInfo> list2 = query2.list();
					if (list2.size() > 0) {
						groupDetail.setOwnerInfo(list2.get(0));
					} else {
						groupDetail.setOwnerInfo(null);
					}
					queryResultList.add(groupDetail);
				}
			}

			// 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 queryResultList;
	}