Building Spring 2 Enterprise Applications phần 6

Bằng cách khai báo các chú thích @ Kiểm toán trên sensitiveOperation () phương pháp, chúng tôi đã chỉ ra chúng ta cần phải lưu giữ thông tin kiểm toán cho phương pháp này. Chúng tôi chưa xác định, tuy nhiên, thông tingiao diện Kiểm toán {} Bây giờ chúng ta có thể sử dụng chú thích này trên lớp BusinessOperations | CHAPTER 5 INTRODUCTION TO DATA ACCESS 161 invoices per member which means the database needs to maintain this relationship. Since it s a one-to-many relationship one member has many invoices one invoice belongs to one member and we re using a relational database we can design the t_invoice table to hold a foreign key of the member member_id that links to the t_player table. When the application wants to load all the invoices for a member from the database it must know the identifier of the member as it does when it wants to insert a new invoice. So it s fair to say that the outlines of the schema in the database ripple through the application. This example will work a bit differently for ORM tools but the logical connection between the database and application will remain. Application code and database schemas will always be connected at some level. The adapter nature has an interesting consequence applications should be built with the database and data access in mind. This means that unless your data-access needs are trivial you will need a fairly accurate database schema in place to find out how fit your application code actually is. Some applications are built believing that no concessions should be made for the data-access requirements. This is a misguided approach to data access that can be linked to the transparency claim of the DAO. When you look closely you will find data-access details rippling through all applications that work with databases. It s impractical and often impossible to hide this. Using the Repository Adapter To demonstrate how the repository adapter works in practice. we re going to rewrite the code in Listings 5-5 and 5-7. We ll start with the NewsletterSubscriptionRepositoryAdapter interface as shown in Listing 5-9. Listing 5-9. The NewsletterSubscriptionRepositoryAdapter Interface package public interface NewsletterSubscriptionRepositoryAdapter void addNewsletterSubscription int memberId String .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.