error: method createQuery in interface EntityManager cannot be applied to given types
Simon Joseph Aquilina
posted 3 years ago
Hello when I try to make use of javax.persistence.TypedQuery I get the error "method createQuery in interface EntityManager cannot be applied to given types". If I make use of javax.persistence.Query I do not get the error (but obviously I have to stay typecasting the result to the wanted object). I did a search on the internet and I found out that this might be a problem with dependencies. I use maven to manage my builds. My original dependencies where as follows:
On the internet I read that TypedQuery where introduced for JPA 2.0 and that I should have used the hibernate stub project for JPA 2.0, i.e.
This did not work either. So I searched for OpenJPA JPA 2.0 library and tried to set this as a dependency, i.e. -
This did not work either! So I was wondering has anyone encountered this problem and actually managed to solve it?
I still get the same error and I cannot understand why!
Note that the error is very strange as it does not fail on the import of javax.persistence.TypedQuery but when I call the createQuery method!