Binding Parameters to a JPQL Query
JPQL allows parameter building queries in two ways: positional or by name. The positional method inserts a number in the string (position) followed by the parameter value (?):
SELECT u FROM User u WHERE u.firstName = ?1 AND u.address.country = ?2
The named parameter method is much like Ruby's parameter query syntax:
SELECT u FROM User u WHERE u.firstName = :firstname AND u.address.country = :country
The parameters, firstName and country, are assumed to have values already assigned to them before the query is executed.