Hibernate Query Language:
Advantages of HQL:
Query Interface:
Methods of Query Interface:
- HQL is one of the feature of Hibernate.
- HQL is same like SQL but here it uses class name as table name and variables as columns.
- HQL is Database independent query language.
- An object oriented form of SQL is called HQL
- HQL syntax is very much similar to SQL syntax. Hibernate Query Language queries are formed by using Entities and their properties, where as SQL quires are formed by using Tables and their columns.
- HQL Queries are fully object oriented..
- HQL Queries are case sensitive.
- Database Independent
- HQL Queries supports inheritance and polymorphism
- Easy to learn.
Query Interface:
- Query interface used to Represent HQL query in the form of query object.
- The object of query will be created by calling createQuery(hql query) method of session.
- Session hsession = sf.openSession();
- Query query = hsession.createQuery(hql query);
- Send the query object to hibernate software by calling the list method.
- Hibernate returns an ArrayList object render the ArrayList object and display the output to client.
- List l = query.list();
- ArrayList emplist = (ArrayList)l;
- Query is an interface which is available as port of org.hibernate package. We can not create the object to query interface. We can create a reference variable and it holds implementation class object.
Methods of Query Interface:
No comments