tailieunhanh - Seam Framework Experience the Evolution of Java EE 2nd phần 3
Trong phần III, chúng tôi sẽ bao gồm hội nhập của các thành phần dữ liệu trực tiếp vào các trang web JSF. Tích hợp trực tiếp như vậy cho phép Seam để thêm các tính năng quan trọng đối với JSF, trong đó có end-to-end xác nhận (Chương 12), dễ dàng sử dụng các bảng dữ liệu (Chương 13), | 78 Simpo PDF Mergếand Split Unregistered Version1- http One of the chief challenges of ORM is to bridge the paradigm rift between the object world and the relational world. A key concept here is lazy loading. When the framework loads an object from the relational database it does not necessarily load all its associated objects. To understand lazy loading let s look at an example. Below is a code snippet from a typical data model A Teacher object can be associated with a number of Student objects each Student object can be associated with a number of Assignment objects etc. Entity public class Teacher implements Serializable protected Long id protected String name protected List Student students getter and setter methods Entity public class Student implements Serializable protected Long id protected List Assignment assignments getter and setter methods Entity public class Assignment implements Serializable . If the ORM framework loads all associated Student and Assignment objects when it loads a Teacher object this is known as eager loading it would issue two SQL JOIN commands and might end up loading a sizable chunk of the database into this single object. Of course when the application actually uses the Teacher object it might not use the students property at all. It might just change the teacher s name and save the object right back to the database. Eager loading is a huge waste of resources in this case. The ORM framework deals with this problem by lazy loading the Teacher object that is not loading any of the Student objects initially at all. Then when the application calls explicitly it goes back to the database to load the students list. So far so good. But the real problem arises when the data access layer of the web application is stateless. For instance let s look at how data is loaded in the very popular Spring framework. When an HTTP request comes in it is dispatched to Spring s Hibernate integration template and .
đang nạp các trang xem trước