Queries are case-insensitive
The from clause
It is good practice to name query aliases using an initial lowercase, in the above example receipt is aliases name and Recipt is POJO Class name and Database Table name is recipt.
from Recipt receipt
OR
from Recipt as receipt
Multiple classes may appear, resulting in a cartesian product or "cross" join.
from Recipt,Branch
from Recipt as receipt,Branch as branch
Associations and joins
We may also assign aliases to associated entities, or even to elements of a collection of values, using a join. The supported join types are borrowed from ANSI SQL
• inner join
• left outer join
• right outer join
• full join (not usually useful)
• inner join
• left outer join
• right outer join
• full join (not usually useful)
The order by clause
The list returned by a query may be ordered by any property of a returned class or components:
from User user order by user.name asc, user.creationDate desc, user.email
from Recipt receipt order by receipt.id desc
from Recipt receipt order by receipt.id asc
The group by clause
A query that returns aggregate values may be grouped by any property of a returned class or components:
HQL QUERY
select name,customerCode , sum(amountInRupees) from Recipt receipt group by receipt.customerCode
SQL QUERY
SELECT name,customer_code ,sum(amount_in_rupees) FROM `recipt` group by customer_code
A having clause is also allowed.
No comments:
Post a Comment