Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPQL -Collection Member Expressions -type mismatch

AmasoniAug 13 2012 — edited Aug 15 2012
I'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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2012
Added on Aug 13 2012
5 comments
718 views