Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is managed and unmanaged environment mean in hibernate?

Tags:

hibernate

I'm new to hibernate. Can anybody explain me what it means when we say, 'Hibernate works in managed and unmanaged environment'?

What is managed and unmanaged environment mean?

Thanks in advance,

-Uday

like image 906
Uday Avatar asked May 29 '11 05:05

Uday


1 Answers

I am not sure about specific context you heard it in. But usually when we say 'managed environment' it means that there is some external container that operates things on your behalf. And in 'unmanaged' case you have do do work to manage your object lifecycle yourself.

For example, if you just use Hibernate by itself, you would need to create session, do your operation and close session. So it is unmanaged since you have to manage it yourself.

However, if you use Hibernate inside Spring container, session open and close will be taken care of for you by Spring. In this case, it is managed for you.

like image 152
Alex Gitelman Avatar answered Oct 26 '22 09:10

Alex Gitelman