code: @SuppressWarnings("unchecked")
  	private void queryForCoursesWithXStudents(int studentCount) {
  		System.out.println(">> Query for courses with " + studentCount + " students:");
  		//using Java method in query
  		Query q = pm.newQuery(Course.class, "students.size() == " + studentCount + "");
  		Collection<Course> courses = (Collection<Course>)q.execute(); 
  		for (Course c : courses) {
  			System.out.println(">> - " + c.getName() + " has size: " + c.getStudents().size());
  		}
  	}
docs: This example demonstrates how many Java methods of Java SE classes can
  be used in queries. Not that not all methods can be used.