Java Persistence with Hibernate phần 2

Sao lưu đậu Tên này sau đó được ánh xạ trong JSF cấu hình cho một lớp đậu thực tế ủng hộ, cùng với một tuyên bố của một thể hiện của lớp đó phải được xử lý bởi JSF (trong yêu cầu, trong phiên HTTP, hoặc trong bối cảnh ứng dụng). Động cơ JSF sẽ tự động giữ lĩnh vực đậu sao lưu (hoặc tài sản) | 54 CHAPTER 2 Starting a project I Nonmanaged JSE environment I i I . r. 7 I Application I I I 1 I I 1 I 1 1 1 main User-managed JCBC Connections Connection Pool 1 1 1 s Database Servlet JSP Figure JDBC connection pooling in a nonmanaged environment With no application server to provide a connection pool an application either implements its own pooling algorithm or relies on a third-party library such as the open source C3P0 connection pooling software. Without Hibernate the application code calls the connection pool to obtain a JDBC connection and then executes SQL statements with the JDBC programming interface. When the application closes the SQL statements and finally closes the connection the prepared statements and connection aren t destroyed but are returned to the pool. With Hibernate the picture changes It acts as a client of the JDBC connection pool as shown in figure . The application code uses the Hibernate Session and Query API for persistence operations and it manages database transactions probably with the Hibernate Transaction API. Hibernate defines a plug-in architecture that allows integration with any connection-pooling software. However support for C3P0 is built in and the software comes bundled with Hibernate so you ll use that you already copied the file into your library directory right . Hibernate maintains the pool for you and configuration properties are passed through. How do you configure C3P0 through Hibernate Figure Hibernate with a connection pool in a nonmanaged environment Database Starting a Hibernate project 55 One way to configure the connection pool is to put the settings into your configuration file like you did in the previous section. Alternatively you can create a file in the classpath root of the application. An example of a file for C3P0 is shown in listing . Note that this file with the exception of a list of mapping resources is equivalent .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
7    733    3    01-07-2024
Đã 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.