@ SuppressWarnings ( "unchecked" ) private void queryForCoursesByTeacher ( String name ) { System . out . println ( ">> Query for courses by teacher " + name + " returned:" ) ; //using reference in query Query q = pm . newQuery ( Course . class , "teacher.name == '" + name + "'" ) ; Collection < Course > courses = ( Collection < Course > ) q . execute ( ) ; for ( Course c : courses ) { System . out . println ( ">> - " + c . getName ( ) + " by " + c . getTeacher ( ) . getName ( ) ) ; } }
Example for a path query on Course . teacher . name == myName .