This might look like a "stupid question" but I still have to ask it since I'm rather confused about it..
What does "managed environment" really mean? (The reason I need to know that right now is because I want to learn how to write a correct Hibernate config. file, but I'll ask more about that in a more appropriate forum.)
I'm currently doing a thesis where I'm investigating what the benefits are of using the Struts and Hibernate frameworks, compared with using just JSPs, servlets and EJBs.
I've already finished my version without the frameworks and now I'm trying to transform it into using Struts and Hibernate. I think I shouldn't use EJBs in this version, so then I guess I have to use a lot of POJOs instead (plus some configuration files and the Struts form- and action classes and JSPs of course). So now I'm wondering: Am I using a managed or non-managed environment?
I was thinking that regular Java classes (POJOS) always are non-managed, but then I read (in some book or article) some examples (but not enough) of what "managed environment" means and one of those examples was "code which runs on an application server" - and I'm not entirely sure that my POJOs don't do that.
I just know that EJB containers mean "managed code" and the book "Hibernate in action" says that a servlet container is a "non-managed environment".
So the real question for me is: Should I use Hibernate configuration for a non-managed environment? (I think the answer is Yes but I'm not completely sure.)
I'd be very happy if someone could shred some light on this issue for me.
Thanks in advance!
Joined: Feb 12, 2008
I forgot to add that I'm using the Sun Application Server 9, and that's a big part of why I'm confused about this matter ('cause I don't know everything that's happening "under the surface" there).
managed transactions (which normally means managed connections, too).
Container Managed Transactions are used in EJBs, servlets are always non-transactional (ok, you can use user transactions, but than the environment is not managed).
For servlets it is possible to use the application server to get the database connection (via JNDI) - then the AS manages the connection for you and does the pooling and so on. Or you can use JDBC directely - then it is unmanaged.
If it comes down to hibernate it depends: do you configure hibernate to use JDNI to get the database connection, you have a managed connection - if you don't use JNDI you have not a managed environment.
Hope this answer helps at least a little bit.
Joined: Feb 12, 2008
Thanks for the reply, Roland!
Yes, it helped a bit. Then I'm using a non-managed environment (for Hibernate) according to an example I've looked at. But the rest of my questions will be about Hibernate so I'll ask them on the Object Relational Mapping forum.