Why is “hibernate.connection.autocommit = true” not recommended in Hibernate?

后端 未结 4 1473
醉梦人生
醉梦人生 2020-12-14 08:40

In Hibernate API, there is a property hibernate.connection.autocommit which can be set to true.

But in the API, they have mentioned that it is not recommended to se

4条回答
  •  别那么骄傲
    2020-12-14 08:49

    By default the autocommit value is false, therefore the transaction needs to be commited explicitly. This might be the reason why the changes not getting reflected in database, else can try flush to force the changes before commit.

    When you close the session, then it will get commited in database implicitly [depends on the implementation].

    When you have cascading transactions & needs to rollback for atomicity, you need to have control over transactions & in that case, autocommit should be false.

    Either set autocommit as true or handle transactions explicitly.

    Here is a good explanation on it.

    Hibernate forum related to this.

    Stackoverflow question on it.

提交回复
热议问题