HQL is to perform both select and non-select operations on the data, but Criteria is only for selecting the data, we cannot perform non-select operations using criteriaHQL是对数据进行选择和非选择操作,但Criteria只是对数据进行选择,不能使用标准进行非选择操作
HQL is suitable for executing Static Queries, where as Criteria is suitable for executing Dynamic QueriesHQL 适用于执行静态查询,而 Criteria 适用于执行动态查询
HQL doesn't support pagination concept, but we can achieve pagination with CriteriaHQL 不支持分页概念,但我们可以通过 Criteria 实现分页
Criteria used to take more time to execute then HQL过去,标准比 HQL 需要更多时间来执行
With Criteria we are safe with SQL Injection because of its dynamic query generation but in HQL as your queries are either fixed or parametrized, there is no safe from SQL Injection.使用 Criteria,我们可以安全地使用 SQL 注入,因为它可以动态生成查询,但在 HQL 中,由于您的查询是固定的或参数化的,因此 SQL 注入没有安全性。