Why does the EntityManager not have the createQuery method with a typed return?

2

I'm following the Spring-MVC book project of House Do Code, using the latest version of Hibernate, 4.0.3.

But at a time, when the book indicated the creation of a quoted query through the following code:

// manager é um objeto da classe javax.persistence.EntityManager
manager.createQuery("minha query", MinhaEntidade.class);

I noticed that my object EntityManager would only respond to a method called createQuery , where the only accepted parameter is String , not another class as the second parameter.

However, can anyone tell me if this method is no longer used, is it my mistake or what might be different from the book project?

    
asked by anonymous 09.11.2015 / 21:58

1 answer

3

This method exists in Java EE 7 (which has JPA 2.1):

link

In Java EE 6 (which has JPA 2.0):

link

But not in Java EE 5 (which has JPA 1.0):

link

Viewing the javadoc from the TypedQuery interface, which is the type of the method you want:

  

Since:
  Java Persistence 2.0

That is, if this method did not appear to you it is because you probably have a JAR to use JPA 1.0, not JPA 2.0 or 2.1.

You can download the latest JAR to use JPA 2.0 (Java EE 6) in hibernate here:

link

Or for JPA 2.1 (Java EE 7):

link

    
09.11.2015 / 22:24