I started learning JPA, and I searched on many sites, and I could not find an explanation regarding this example:
Implementing a query using @NamedQuery:
@Entity
@NamedQuery(
name="findAllEmployeesByFirstName",
queryString="SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = 'John'"
)
public class Employee implements Serializable {
...
}
I just donโt understand why the author selects the object (emp) .. why he doesnโt use something like this SELECT emp FROM Employee emp WHERE emp.firstName = 'John'
Is there any difference? Did I miss something?
source
share