@Override
	public int listFriends(int requesterID, int profileOwnerID,
			Set<String> fields, Vector<HashMap<String, ByteIterator>> result, boolean insertImage, boolean testMode) {
		if(requesterID < 0 || profileOwnerID < 0)
			return -1;

		session = sessionFactory.openSession();
		try {
			tx = session.beginTransaction();
			Criterion t1 = Restrictions.eq("inviteeid", Integer.toString(profileOwnerID));
			Criterion t2 = Restrictions.eq("inviterid", Integer.toString(profileOwnerID));
			
			List<Friendship> obj = session.createCriteria(Friendship.class)
					.add(Restrictions.and(Restrictions.or(t1,t2),
											Restrictions.eq("value", Integer.toString(2))))
					.setCacheable(true)
					.list();
			Map<String, Method> methods = FactoryInsert.getGetterMethods(USERS.class);
			Set<String> keys;
			if (fields == null){
				keys = methods.keySet();
				keys.remove("confFriendCnt");
				keys.remove("pendFriendCnt");
				keys.remove("resCnt");
			}
			else
				keys = fields;
			
			HashMap<String, ByteIterator> uDetails;
			for(Friendship f : obj){
				uDetails = new HashMap<String, ByteIterator>();
				USERS user = (USERS) session.get(USERS.class, f.getInviterid());
				Iterator<String> it = keys.iterator();
				while(it.hasNext()){
					String key = it.next();
					if(!insertImage && (key.equalsIgnoreCase("pic") || key.equalsIgnoreCase("tpic")))
						continue;
					Method methd = methods.get(key);
					Object r = methd.invoke(user, null);
					uDetails.put(key, new ObjectByteIterator(r.toString().getBytes()));
//					System.out.println("listing friends of: "+profileOwnerID);
				}
				result.add(uDetails);
			}
			
			tx.commit();
//			System.out.println("listed friends of: "+profileOwnerID);
			return 0;
		}catch (Exception e) {
			System.out.println("list friend: "+ profileOwnerID);
			e.printStackTrace(System.out);
			return -1;
		}
		finally{
			session.close();
		}
	}