简体   繁体   English

Hibernate线程中是否有CUD操作安全?

[英]Are there CUD operations in Hibernate thread safe?

Could you please explain how CUD operations in Hibernate work with multithreading? 您能否解释一下Hibernate中的CUD操作如何与多线程一起使用? And are they threadsafe? 而且它们是线程安全的吗? For example, two threads create users in same time, what will be with id? 例如,两个线程同时创建用户,id将是什么? Is there any synchronization? 有同步吗?

You have to consider the hibernate session only. 您只需要考虑休眠会话。 Its not sharable among threads. 它在线程之间不可共享。 So each thread will have its own db session object and execute the query. 因此,每个线程将具有其自己的数据库会话对象并执行查询。 Thats it. 而已。 Nothing with hibernate CUD its all depends on how you have created your DAO / Repository objects with proper db session handling. 休眠CUD的全部内容都取决于您如何通过适当的数据库会话处理来创建DAO /存储库对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM