Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Subselect TỪ-khoản là một liên minh của tất cả các bảng lớp bê tông, và nó bao gồm các giá trị chính nước ngoài user_id cho tất cả các trường hợp. Chọn bên ngoài hiện nay bao gồm một hạn chế trong mệnh đề WHERE để tất cả các hàng tham khảo một người dùng cụ thể. Ma thuật này hoạt động rất tốt để thu hồi dữ liệu. | 318 CHAPTER 7 Advanced entity association mappings Hibernate executes a UNION query to retrieve all instances that are referenced in this collection select BD. from select BILLING_DETAILS_ID USER_ID OWNER NUMBER EXP_MONTH EXP_YEAR null as ACCOUNT null as BANKNAME null as SWIFT 1 as CLAZZ from CREDIT_CARD union select BILLING_DETAILS_ID USER_ID OWNER null as NUMBER null as EXP_MONTH null as EXP_YEAR ACCOUNT BANKNAME SWIFT 2 as CLAZZ from BANK_ACCOUNT BD where BD.USER_ID The FROM-clause subselect is a union of all concrete class tables and it includes the USER_ID foreign key values for all instances. The outer select now includes a restriction in the WHERE clause to all rows referencing a particular user. This magic works great for retrieval of data. If you manipulate the collection and association the noninverse side is used to update the USER_ID column s in the concrete table. In other words the modification of the inverse collection has no effect The value of the user property of a CreditCard or BankAccount instance is taken. Now consider the many-to-one association defaultBillingDetails again mapped with the DEFAULT_BILLING_DETAILS_ID column in the USERS table. Hibernate executes a UNION query that looks similar to the previous query to retrieve this instance if you access the property. However instead of a restriction in the WHERE clause to a particular user the restriction is made on a particular BILLING_DETAILS_ID. Important Hibernate cannot and will not create a foreign key constraint for DEFAULT_BILLING_DETAILS_ID with this strategy. The target table of this reference can be any of the concrete tables which can t be constrained easily. You should consider writing a custom integrity rule for this column with a database trigger. Polymorphic associations 319 One problematic inheritance strategy remains table per concrete class with implicit polymorphism. 7.3.4 Polymorphic table per concrete class In chapter 5 section 5.1.1 Table per concrete class with implicit