Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 set it like so:

Enables autocommit for JDBC pooled connections (it is not recommended).

Why is it not recommended ? What are the ill-effects of setting this property to true ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
323 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...