1. When automatic versioning is used, hibernate generates the following sql:
update products set version=?, name=?, description=?, unitCost=?, pubTime=? where id=? and version=?
Note that using such sql, you don't need to select the version from database to compare with current version.
2. Other ways to resolve LazyInitializationException, except Open Session in View.
3. Note that for the Transaction in jta, you can register a Synchronization, through this you can be informed before or aftter transaction commit, is Hibernate use this way to flush?
Confirmed that hibernate will register a Synchronization to JTA Transaction.
4. Hibernate3 use event-listener pattern to implement varied operations (like save(), update()...)
5. There are 3 transaction release mode : after statement, after transaction (default since 3.2), on close (after session close). Note that though connection is released "after transaction", it has no impact on lazy load, it just starts a new transaction.
6. TransactionFactory.Context (actually a session), JDBCContext are context for Transaction, which contains Transaction instance and provide methods for Transaction to call (callback). JDBCContext.Context (actually a session) are context for JDBCContext.
JDBCContext is also used by Session to delegate method calls for transaction and connection management.
7. SessionImpl can be nested in tree style, and they share the same timestamp, jdbcContext, interceptor and listeners.
8. Who calls TransactionFactory.Context and JDBCContext's before/after method? Both CacheSynchronization and Transaction will do.
9. Can I call the save() method without starting a new transaction? Yes, in case of JTA or CMT, the transaction is already started, for JDBC, it also starts a new transaction for JDBC dose not need to call a begin() method.
10. Why jta transaction and jdbc transaction's code style should be different? Hibernate provides JTA/CMT Transaction in order to support change to use JTA/CMT from JDBC without code change, so JTA and CMT can use JDBC transaction style, also, they can use their own style.
11. Explain JDBCContext's registerCallbackIfNecessary() and registerSynchronizationIfPossible() method. A callback is needed in order to flush before transaction commit, this callback can either be CacheSynchronization that register itself to jta transaction, or hibernate's JDBC/JTA/CMT Transaction. The registerSynchronizationIfPossible() method use CacheSynchronization, while registerCallbackIfNecessary() use hibernate's transaction object. The registerCallbackIfNecessary() method return true if callback is needed, if registerSynchronizationIfPossible() or registerCallbackIfNecessary() was called before, it will return false.
12. Those TransactionManagerLookup implementations are used by JTATransactionManager and also SessionFactoryImpl (whose getTransactionManager() method is used by JDBCContext's registerSynchronizationIfPossible()).
13. Can omit flush and close session before JTA transaction commit? I believe not, when transaction commit, session will flush and at that time session is closed, but still need to test.
Also, dose jta transaction need to begin before opening a new session? I believe not too.
14. Can omit hibernate.transaction.factory_class setting? If incorrect factory class is specified, Interceptor will get incorrect type of Transaction and fail to retrieve correct state from that transaction. If hibernate transaction objects are used by client code, incorrect factory class will cause error.
15. How hiberate detect the type of transaction to use automatically? Hibernate will first try to find out whether a callback is registered and use TransactionManager to see if there's currently a transaction, if yes, it will register a synchronization, if no, it will rely on client code to call hibernate's transaction objects.
16. Relationship between TransactionFactory, Transaction, TransactionManagerLookup, CacheSynchronization, JDBCContext, Interceptor.
![](/upload/attachment/68539/44d7838d-cef8-3daf-a00d-4c0f87b904f7.png)
![](/upload/attachment/68541/a260ae0b-6f01-3941-8232-6f4a693b87c7.png)
- -! Gavin King 's comment at TransactionManagerLookup.getTransactionIdentifier: "This method was added specifically for use in WebSphere and other unfriendly JEE containers (although WebSphere is still the only known such brain-dead, sales-driven impl)."
![点击查看原始大小图片](http://dl2.iteye.com/upload/attachment/0006/8539/44d7838d-cef8-3daf-a00d-4c0f87b904f7-thumb.png)
- 大小: 8.7 KB
![点击查看原始大小图片](http://dl2.iteye.com/upload/attachment/0006/8541/a260ae0b-6f01-3941-8232-6f4a693b87c7-thumb.png)
- 大小: 15.7 KB
分享到:
相关推荐
Python 3.9.13 - May 17, 2022 Note that Python 3.9.13 cannot be used on Windows 7 or earlier.
Nvidia-Driver-531.79-notebook-win10-win11-64bit-dch-whql.exe
1、安装NoteExpress 2.9.8.5668 2、安装Registry.Trash.Keys.Finder_3.9.2.0 3、破解Registry.Trash.Keys.Finder_3.9.2.0:用crash目录下X86或者X64(看个人系统)目录下的TrashRegFull.exe,替换安装目录下的...
09. Hibernate note.txt 10_1. HTML&CSS note.txt 10_2. JavaScript note.txt 11. Servlet note.txt 12. JSP note.txt 13. AJAX Note.txt 14. Struts1.x note.txt 14. Struts2.x note.txt 15. Spring note.txt 16. ...
Aspose.BarCode for .NET 16.12.1 (12/13/2016) Aspose.Imaging for .NET 16.12 (12/30/2016) Aspose.Tasks for .NET 16.11.0 (11/17/2016) Aspose.OCR for .NET 17.01 (1/14/2017) Aspose.Diagram for ...
NoteExpress_2.8.1.2024_zh 及最新注册码(13-4-20亲测有效)
09. Hibernate note.txt 10_1. HTML note.txt 10_2. JavaScript note.txt 11. Servlet note.txt 12. JSP note.txt 13. AJAX Note.txt 14. Struts1.x note.txt 14. Struts2.x note.txt 15. Spring note.txt 16. EJB ...
NoteExpress_2.2.0.674中文文献管理软件,超好用。
NoteExpress_3.7.0.9258_zh.exe
小米Note专用recovery TWRP-20190418-3.3.0.0-2022-04-21-virgo
NoteExpress是国内最专业的文献检索与管理系统,完全支持中文,NoteExpress 可以帮助您通过各种方途径高效,自动的搜索(含互联网),下载,管理文献资料和研究论文。该软件可嵌入MS Word环境使用,在使用Word中输出...
2-8 2.2.3 Product Register (P, PH, PL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 2.2.4 Data Page Pointer (DP) . . . . . . . . . . . . . . . . . . . . . ....
荣耀10青春版 HRY-AL00/TL00 9.0.1.111以上版本 荣耀V10 BKL-AL00 8.0.0.202 荣耀V10 BKL-AL00 8.0.0.203 荣耀V10 BKL-AL00 8.0.0.204 荣耀V10 BKL-AL20 8.0.0.202 荣耀V10 BKL-AL20 8.0.0.203 荣耀V10 BKL-AL20 8.0...
NoteExpress_3.2.0.7264_zh
1.1. Part 1 - The first Hibernate Application ................................................................ 1 1.1.1. Setup .............................................................................
NoteExpress_3.7.0.9296_zh.exe
TWRP-3.3.0-0517-REDMI_NOTE7-CN-wzsx150-fastboot.7z
Summary.....................................................................................................................1-13 Exercises Exercise 1-1 Running a Sequence File............................
NoteExpress.rar工具,包括软件,文档,以及简要的说明信息