91-9990449935 0120-4256464 |
HCQL (Hibernate Criteria Query Language)The Hibernate Criteria Query Language (HCQL) is used to fetch the records based on the specific criteria. The Criteria interface provides methods to apply criteria such as retreiving all the records of table whose salary is greater than 50000 etc. Advantage of HCQLThe HCQL provides methods to add criteria, so it is easy for the java programmer to add criteria. The java programmer is able to add many criteria on a query. Criteria InterfaceThe Criteria interface provides many methods to specify criteria. The object of Criteria can be obtained by calling the createCriteria() method of Session interface. Syntax of createCriteria() method of Session interfaceThe commonly used methods of Criteria interface are as follows:
Restrictions classRestrictions class provides methods that can be used as Criterion. The commonly used methods of Restrictions class are as follows:
Order classThe Order class represents an order. The commonly used methods of Restrictions class are as follows:
Examples of Hibernate Criteria Query LanguageThere are given a lot of examples of HCQL. Example of HCQL to get all the recordsExample of HCQL to get the 10th to 20th recordExample of HCQL to get the records whose salary is greater than 10000Example of HCQL to get the records in ascending order on the basis of salaryHCQL with ProjectionWe can fetch data of a particular column by projection such as name etc. Let's see the simple example of projection that prints data of NAME column of the table only.
Next TopicHibernate Named Query
|