gpt4 book ai didi

java - sessionfactory.openSession() 和 sessionfactory.openStatelessSession() 的区别?

转载 作者:太空狗 更新时间:2023-10-29 22:55:52 29 4
gpt4 key购买 nike

我想知道上面提到的 hibernates sessionfactory 类的两种方法之间的概念差异,如果可以通过简单的例子。

最佳答案

前者打开一个正常(有状态) session ,而后者(可能不足为奇)打开一个无状态 session

根据 the Javadoc ,无状态 session 是:

A command-oriented API for performing bulk operations against a database.

A stateless session does not implement a first-level cache nor interact with any second-level cache, nor does it implement transactional write-behind or automatic dirty checking, nor do operations cascade to associated instances. Collections are ignored by a stateless session. Operations performed via a stateless session bypass Hibernate's event model and interceptors. Stateless sessions are vulnerable to data aliasing effects, due to the lack of a first-level cache.

For certain kinds of transactions, a stateless session may perform slightly faster than a stateful session.

关于java - sessionfactory.openSession() 和 sessionfactory.openStatelessSession() 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5496995/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com