software <-m:n-> tag
I want to create query for selecting all softwares where tag.id = id
I write:
TypedQuery query =
Software.em().createQuery(
"SELECT DISTINCT s FROM Software s INNER JOIN s.tags WHERE s.tags.id = :tagId",
Software.class
);
query.setParameter("tagId", tagId);
as result i have:
A java.lang.IllegalArgumentException
has been caught,
org.hibernate.QueryException: illegal
attempt to dereference collection
[software0_.id.tags] with element
property reference [id] [SELECT
DISTINCT s FROM models.Software s
INNER JOIN s.tags WHERE s.tags.id =
:tagId]
How could I implement it? and why I have such exception?
I think the problem might be that you are missing the FROM clause in your statement.
The error “Unexpected token: INNER” is given because it expects a FROM.
Try the following query: