I wonder why I got "An identification variable must be provided for a range variable declaration." error when I don't have alias.
Seems like I solved by problem when I added alias to the table.
Code with problem:
List result = entityManager.createQuery( "from Rental", Rental.class ).getResultList();
Solution:
List result = entityManager.createQuery( "from Rental r", Rental.class ).getResultList();
You should make a distinction between HQL
(Hibernate Query Language) and JPQL
(Java Persistence Query Language). As long as your provider is Hibernate you will see no difference, but you have to remember that correct JPQL
query consists of SELECT
keyword. Here's explanation of this differences.
Going back to you question - it is JPQL
requirement to define alias for each Entity table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With