public void test() { ReadAllQuery query = new ReadAllQuery(Employee.class); query.dontMaintainCache(); query.addPartialAttribute("nonExistant"); try { getSession().executeQuery(query); } catch (QueryException exception) { if (exception.getErrorCode() == QueryException.SPECIFIED_PARTIAL_ATTRIBUTE_DOES_NOT_EXIST) { correctException = true; } else { correctException = false; throw exception; } } }