For a parameter other than a String or an int, I believe you need to use declareParameters instead. Try something like this:
Query q = pm.newQuery(com.xxx.yyy.User.class);
q.setFilter("role == p1"); //p1 is a variable place holder
q.declareParameters("Enum p1"); //here you define the data type for the variable, in this case an Enum
q.setRange(0, 50);
q.setOrdering("key desc");
AbstractQueryResult results = (AbstractQueryResult) pm.newQuery(q).execute(admin);
or if you want more gql like syntax -
Query query = pm.newQuery("SELECT FROM com.xxx.yyy.User WHERE role == p1 ORDER BY key desc RANGE 0,50");
query.declareParameters("Enum p1");
AbstractQueryResult results = (AbstractQueryResult) pm.newQuery(q).execute(admin);