`
semi_sleep
  • 浏览: 101130 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Note for hibernate 2009.1.8 - 2009.1.13

阅读更多

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.





  

 

- -! 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)."

  • 大小: 8.7 KB
  • 大小: 15.7 KB
分享到:
评论

相关推荐

    Nvidia-Driver-531.79-notebook-win10-win11-64bit-dch-whql.exe

    Nvidia-Driver-531.79-notebook-win10-win11-64bit-dch-whql.exe

    NoteExpress 2.9.8.5668破解(2014-04-01)

    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,替换安装目录下的...

    NoteExpress_3.7.0.9258_zh.exe

    NoteExpress_3.7.0.9258_zh.exe

    python-3.9.13-amd64安装包

    为了充分利用Python 3.9.13,开发者应确保他们的开发环境满足其系统需求,并考虑升级到支持的Windows版本,或者在其他支持的操作系统(如Windows 8、10,macOS,Linux等)上使用。同时,定期更新到最新版本的Python...

    计算机软件编程学习笔记.rar

    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.Total for .NET 2017-01-26 破解版 第一分卷

    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亲测有效)

    本文将详细解析NoteExpress 2.8.1.2024_zh版本及其相关知识点。 首先,NoteExpress的核心功能是文献检索与管理。它支持多种国内外知名数据库,如Web of Science、PubMed、CNKI等,用户可以直接在软件内搜索并下载...

    达内培训五个月以来的笔记:tarena_note

    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 ...

    小米Note专用recovery TWRP-20190418-3.3.0.0--2022-04-21-virgo

    【小米Note专用recovery:TWRP-20190418-3.3.0.0--2022-04-21-virgo】 本主题涉及的是小米Note手机的定制恢复环境——Team Win Recovery Project(TWRP)的一个特定版本,即TWRP 3.3.0.0。TWRP是一款广受欢迎的开源...

    【浏览器插件】NoteExpress 网络捕手.zip

    【浏览器插件 - NoteExpress 网络捕手】轻松将网页文献一键保存至NoteExpress,为您的学术研究提供高效便捷的资料收集工具。请注意,此插件需与NoteExpress软件配合使用,并且目前仅支持Windows操作系统。

    ti dsp tms2802芯片资料

    2-8 2.2.3 Product Register (P, PH, PL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 2.2.4 Data Page Pointer (DP) . . . . . . . . . . . . . . . . . . . . . ....

    华为EMUI8.0-8.2免APP手撕解华为ID账户锁教程

    荣耀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.exe

    NoteExpress_3.2.0.7264_zh

    NoteExpress_2.8.1.2024-破解版

    NoteExpress是国内最专业的文献检索与管理系统,完全支持中文,NoteExpress 可以帮助您通过各种方途径高效,自动的搜索(含互联网),下载,管理文献资料和研究论文。该软件可嵌入MS Word环境使用,在使用Word中输出...

    TWRP-3.3.0-0517-REDMI_NOTE7-CN-wzsx150-fastboot.7z

    1. **recovery-twrp一键刷入工具.bat**:这是一个批处理文件,用于简化TWRP的刷入过程,用户只需按照提示操作即可完成刷入。 2. **打开CMD命令行.bat**:这是另一个批处理文件,可能用于快速启动命令提示符窗口,...

    NoteExpress_3.7.0.9296_zh.exe

    NoteExpress_3.7.0.9296_zh.exe

    Labview TestStand教程

    Summary.....................................................................................................................1-13 Exercises Exercise 1-1 Running a Sequence File............................

    node - v16.19.0-x64.msi

    Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行时

    noteexpress3.2.0.7409.rar

    NoteExpress具备文献信息检索与下载功能,可以用来管理参考文献的题录,以附件方式管理参考文献全文或者任何格式的文件,文档。数据挖掘的功能可以帮助用户快速了解某研究方向的最新进展,各方观点等。除了管理以上...

Global site tag (gtag.js) - Google Analytics