for (int j = 0; j < split.length; ++j) {
for (int j = 0; j < split.length && obj != null; ++j) {
    protected static String createHQLQuery(Object object, HashMap corres) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {	    StringBuffer query = new StringBuffer();	    	    for (Iterator i = corres.keySet().iterator(); i.hasNext();) {	        String methodName = (String) i.next();	        String attributeName = (String) corres.get(methodName);	        String[] split = null;	        if (methodName.indexOf(".") != -1)	            split = methodName.split("\\.");	        else	            split = new String[] { methodName };	        Object obj = object;	        for (int j = 0; j < split.length; ++j) {	            Class clazz = obj.getClass();	            obj = clazz.getMethod("get"+split[j], (java.lang.Class[]) null).invoke(obj, (java.lang.Object[]) null);	        }	        if (obj != null) {		        if (query.length() != 0)			        query.append(" AND ");		        if (obj instanceof String)		            obj = ((String) obj).replaceAll("'","''");		        query.append(attributeName).append("='").append(obj).append("'");	        }	    }		    		return query.toString();    }