tailieunhanh - Java Persistence with Hibernate 2nd phần 2

để thiết bị xuất chuẩn chỉ là lựa chọn đầu tiên đăng nhập của bạn. Hibernate (và nhiều hiện thực ORM khác) thực hiện các câu lệnh SQL không đồng bộ. Một tuyên bố INSERT thường không thực hiện khi ứng dụng gọi (), (s) trong bảng cụ thể. Nói cách khác, sự thay đổi của bộ sưu tập ngược không có tác dụng: | 58 CHAPTER 2 Starting a project comments inside all generated SQL statements to hint at their origin. For example you can then easily see if a particular SQL statement was generated from an explicit query or an on-demand collection initialization. Enabling the SQL output to stdout is only your first logging option. Hibernate and many other ORM implementations execute SQL statements asynchronously. An INSERT statement isn t usually executed when the application calls nor is an UPDATE immediately issued when the application calls . Instead the SQL statements are usually issued at the end of a transaction. This means that tracing and debugging ORM code is sometimes nontrivial. In theory it s possible for the application to treat Hibernate as a black box and ignore this behavior. However when you re troubleshooting a difficult problem you need to be able to see exactly what is going on inside Hibernate. Because Hibernate is open source you can easily step into the Hibernate code and occasionally this helps a great deal Seasoned Hibernate experts debug problems by looking at the Hibernate log and the mapping files only we encourage you to spend some time with the log output generated by Hibernate and familiarize yourself with the internals. Hibernate logs all interesting events through Apache commons-logging a thin abstraction layer that directs output to either Apache Log4j if you put in your classpath or JDK logging if you re running under JDK or above and Log4j isn t present . We recommend Log4j because it s more mature more popular and under more active development. To see output from Log4j you need a file named in your classpath right next to or . Also don t forget to copy the library to your lib directory. The Log4j configuration example in listing directs all log messages to the console. Listing An example configuration file .

TỪ KHÓA LIÊN QUAN