TAILIEUCHUNG - Hibernate Tutorial 09

When using JDBC to access databases, we write SQL statements for the query and update tasks. In such case, we are dealing with tables, columns and joins. | Hibernate Tutorial 09 Hibernate Query Language By Gary Mak hibernatetutorials@ September 2006 1. Querying objects When using JDBC to access databases we write SQL statements for the query and update tasks. In such case we are dealing with tables columns and joins. When using Hibernate most update tasks can be finished through the APIs provided by Hibernate. However using a query language for the query tasks is still necessary. Hibernate is providing a powerful query language called Hibernate query language HQL . HQL is database independent and translated into SQL by Hibernate at runtime. When writing HQL we can concentrate on the objects and properties without knowing much detail on the underlying database. We can treat HQL as an object-oriented variant of SQL. In the previous chapters we have already experienced some basic HQL statements for querying objects. For example we can use the following HQL to query for all books and then call the list method to retrieve the result list which containing book objects. Query query from Book List books The Query interface provides two methods for retrieving only a subset of the results ranged by the offset which is zero-based and record count. They are very useful for displaying the results in a table with multiple pages. Query query from Book 20 10 List books Another query attribute that will have performance impact is the fetch size. It tells the underlying JDBC driver how many rows should be transferred for a single request. Query query from Book 100 List books When using HQL we can specify query parameters at the same way as we do for SQL queries. If we are sure that there will be only one unique object returned as result we can call the uniqueResult method to retrieve it. Null will be returned if nothing matched. Page 1 of 8 Query query

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.