@SuppressWarnings("rawtypes")
    protected List findByQueryAndNamedParams(String queryString, String[] paramNames, Object[] values) {
        if (paramNames.length != values.length) {
            throw new IllegalArgumentException("Length of paramNames array must match length of values array");
        }
        Session session = getCurrentSession();
        Query queryObject = session.createQuery(queryString);
        if (values != null) {
            for (int i = 0; i < values.length; i++) {
                String paramName = paramNames[i];
                Object value = values[i];
                if (value instanceof Collection) {
                    queryObject.setParameterList(paramName, (Collection<?>) value);
				} else if (value instanceof Object[]) {
					queryObject.setParameterList(paramName, (Object[]) value);
				} else if (value instanceof Long) {
					queryObject.setLong(paramName, (Long) value);
				} else {
					queryObject.setParameter(paramName, value);
				}
            }
        }
        return queryObject.list();
    }