Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是否必须在每个函数中打开和关闭会话和事务(制作对象、删除对象、findbyID)
你能给我一个 findall 的 DAO 实现吗(延迟初始化)。
对于每个完整的业务操作,您都应该有一个事务。I 例如:该操作包括选择一些值、更新它和插入其他值。如果每个基本操作都创建自己的事务,您将无法编写多用户应用程序。
您应该在业务操作开始时创建会话,创建事务,然后在该事务中执行所有操作(您的“功能”),并一起提交或回滚它们。
事务在业务层中定义。