The AS clause can be used to assign aliases to the classes in your HQL queries, specially when you have long queries. For instance, our previous simple example would be the following:
String hql ="FROM Employee AS E";
Query query =session.createQuery(hql); List results =query.list(); The AS keyword is optional and you can also specify the alias directly after the class name, as follows:
String hql ="FROM Employee E";
Query query =session.createQuery(hql); List results =query.list(); |