I am trying a typedQuery that is giving me the following error: java.lang.IllegalArgumentException: Cannot create element join for a collection of non-entities!
I am using JPA 2.0
My code:
@Entity
public class Example {
@ElementCollection(targetClass=ExampleData .class,fetch = FetchType.EAGER)
@MapKeyColumn(name = "locale_key")
@CollectionTable(name = "exampleLocalizedData", joinColumns = @JoinColumn(name = "exampleId"))
private Map<String, IExampleData> exampleLocalizedData;
}
@Embeddable
public class ExampleData {
private String data;
.....
}
My query :
String querySentence = "SELECT DISTINCT e FROM Example e WHERE e.exampleLocalizedData[:locale].name LIKE :filter ";
TypedQuery<Example > actualQuery = entityManager.createQuery(querySentence, Example .class);
My question is, which is the correct query for doing this?
Regards.
edit:
final query if any wants to know :
select DISTINCT e FROM Example e join e.exampleLocalizedData r WHERE index(r) = :locale AND r.name LIKE :filter .