Is Hibernate's session thread safe?

后端 未结 5 887
名媛妹妹
名媛妹妹 2020-12-06 00:01

I need to know, whether the Hibernate\'s session is thread safe or not. But obvious a new session is attached to every thread for execution. But my question is if in one thr

5条回答
  •  执笔经年
    2020-12-06 00:52

    It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.

    Even with this in mind, your behaviour might still not be what you expect, because transactions come into play. You will have to set a proper transaction isolation level. See the configuration guide, hibernate.connection.isolation property.

提交回复
热议问题