TAILIEUCHUNG - Java Persistence with Hibernate 2nd phần 9

Cũng lưu ý rằng các truy vấn ban đầu là chạy lại như một subselect chỉ nhớ Hibernate cho một kỳ họp đặc biệt. Nếu bạn tách một thể hiện mục mà không cần khởi tạo bộ sưu tập của hồ sơ dự thầu, và sau đó lắp lại nó và bắt đầu lặp lại thông qua bộ sưu tập, không tìm nạp trước các bộ sưu tập khác xảy ra. | 664 CHAPTER 15 Advanced query options This chapter explains all query options that you may consider optional or advanced. You ll need the first subject of this chapter the Criteria query interface whenever you create more complex queries programmatically. This API is much more convenient and elegant than programmatic generation of query strings for HQL and JPA QL. Unfortunately it s also only available as a native Hibernate API Java Persistence doesn t yet standardize a programmatic query interface. Both Hibernate and Java Persistence support queries written in native SQL. You can embed SQL and stored procedure calls in your Java source code or externalize them to mapping metadata. Hibernate can execute your SQL and convert the resultset into more convenient objects depending on your mapping. Filtering of collections is a simple convenience feature of Hibernate you won t use it often. It helps you to replace a more elaborate query with a simple API call and a query fragment for example if you want to obtain a subset of the objects in a collection. Finally we ll discuss the optional query result cache we ve already mentioned that it s not useful in all situations so we ll take a closer look at the benefits of caching results of a query and when you d ideally enable this feature. Let s start with query by criteria and query by example. Querying with criteria and example The Criteria and Example APIs are available in Hibernate only Java Persistence doesn t standardize these interfaces. As mentioned earlier it seems likely that other vendors not only Hibernate support a similar extension interface and that a future version of the standard will include this functionality. Querying with programmatically generated criteria and example objects is often the preferred solution when queries get more complex. This is especially true if you have to create a query at runtime. Imagine that you have to implement a search mask in your application with many check boxes input .

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.