JPQL -Collection Member Expressions -type mismatch
AmasoniAug 13 2012 — edited Aug 15 2012I'm trying to run the query below but I get an error
Caused by: java.lang.IllegalArgumentException: You have attempted to set
a value of type class java.lang.String for parameter contid with expected type
of class mmis.entity.Contract from
query string SELECT c FROM Consultant c WHERE c.contractCollection IS EMPTY
OR :contid NOT MEMBER OF c.contractCollection .
public List<Consultant> getAvailableConsultants( String cntrctId) {
return em.createQuery("SELECT c FROM Consultant c"
+ " WHERE c.contractCollection IS EMPTY OR :contid NOT MEMBER OF c.contractCollection ")
.setParameter("contid", cntrctId)
.getResultList();
}
The collection is a result of a many-to-many relationship which i thought holds the contractIDs
how can i get the query to check whether the parameter contid is not in the collection
Thnx