You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by הילה <hi...@gmail.com> on 2011/04/03 01:57:49 UTC

Hibernate in Tomcat

Hey guys,

I tried to explore a bit the possibility of hibernate in tomcat, but some
things aren't that clear for me.
Before hitting the specific questions, please explain what is hibernate in
Tomcat, when do we want to use it, how do I use it specifically with the
JDBC connection pool (instead of the default DBCP connection pool), and if
misconfiguration of the hibernate can cause disconnections of users on the
application (that uses tomcat).

Now for 2 specific questions, if I may :]
1. in this article, its states that hibernate can be used for managing the
JDBC connection pool, but the strings are for c3p0 pool-
http://community.jboss.org/wiki/UsingHibernatewithTomcat
why is that?

2. Do I have to use hibernate.properties file, or can I rename it to
x.properties and still use the content of the hibernate settings?

Thanks
Hila

[OT] Re: Hibernate in Tomcat

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message ----
From: הילה - צוות אגורה <hi...@agora.co.il>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Sat, April 2, 2011 11:35:36 PM
Subject: Re: Hibernate in Tomcat

what is the hibernate mailing list address?
hibernate@tomcat.apache.org? :]

Thanks
Hila


----- Original Message ----

Google is your friend:

https://lists.jboss.org/mailman/listinfo
https://lists.jboss.org/mailman/listinfo/hibernate-users

. . . . just my two cents

/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Hibernate in Tomcat

Posted by הילה - צוות אגורה <hi...@agora.co.il>.
what is the hibernate mailing list address?
hibernate@tomcat.apache.org? :]

Thanks
Hila

2011/4/3 Mark Eggers <it...@yahoo.com>

> ----- Original Message start (edited) ----
> Hey guys,
>
> I tried to explore a bit the possibility of hibernate in tomcat, but some
> things aren't that clear for me.
> Before hitting the specific questions, please explain what is hibernate in
> Tomcat, when do we want to use it, how do I use it specifically with the
> JDBC connection pool (instead of the default DBCP connection pool), and if
> misconfiguration of the hibernate can cause disconnections of users on the
> application (that uses tomcat).
>
> Now for 2 specific questions, if I may :]
> 1. in this article, its states that hibernate can be used for managing the
> JDBC connection pool, but the strings are for c3p0 pool-
> http://community.jboss.org/wiki/UsingHibernatewithTomcat
> why is that?
>
> 2. Do I have to use hibernate.properties file, or can I rename it to
> x.properties and still use the content of the hibernate settings?
>
>
> ----- Original Message end (edited) ----
>
> There's an example on how to configure Hibernate and Tomcat on the Tomcat
> Wiki.
> It's a bit old, but should still be valid.
>
> http://wiki.apache.org/tomcat/TomcatHibernate
>
> Hibernate does some nice things, such as making mapping between a
> relational
> database and objects easier, lazy loading, and loading classes through
> related
> tables into their proper classes. It also has interfaces to secondary
> caches
> (default is ehcache), which reduces the need to query a database for
> read-mostly
> information.
>
> In some of the more complex uses, the Hibernate documents recommend using
> thread
> local variables and filters to manage Hibernate sessions. This can get a
> bit
> tricky if you're not careful.
>
> You can do all of this manually with JNDI, some home-grown wrapper classes
> to
> manage relational-object mapping, and a caching implementation of your
> choice.
> However, Hibernate (or EclipseLink / JPA 2) makes doing this a bit easier.
>
> Can a misconfigured Hibernate application cause users to be disconnected?
> Usually a misconfigured Hibernate application will refuse to start.
> Sometimes if
> your resource mapping is incorrect, the application will start, but those
> resources (and queries) will not function.
>
> C3P0 pooling is the one included with Hibernate. Hibernate used to (2.x)
> include
> an interface to Apache DBCP, but this is no longer available in Hibernate
> 3.x.
> Thus, all of the pooling examples are written for C3P0.
>
> You can use any file that is found on the classpath. However, the default
> is
> hibernate.cfg.xml. To change the default, change the following code from:
>
> SessionFactory sf = new Configuration()
>  .configure()
>  .buildSessionFactory();
>
> to:
>
> SessionFactory sf = new Configuration()
>  .configure("catdb.cfg.xml")
>  .buildSessionFactory();
>
> where "catdb.cfg.xml" is the name you've given to the file.
>
> Further Hibernate questions are probably best answered on the Hibernate
> mailing
> lists or the Hibernate forum.
>
> . . . . just my two cents
>
> /mde/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Hibernate in Tomcat

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message start (edited) ----
Hey guys,

I tried to explore a bit the possibility of hibernate in tomcat, but some
things aren't that clear for me.
Before hitting the specific questions, please explain what is hibernate in
Tomcat, when do we want to use it, how do I use it specifically with the
JDBC connection pool (instead of the default DBCP connection pool), and if
misconfiguration of the hibernate can cause disconnections of users on the
application (that uses tomcat).

Now for 2 specific questions, if I may :]
1. in this article, its states that hibernate can be used for managing the
JDBC connection pool, but the strings are for c3p0 pool-
http://community.jboss.org/wiki/UsingHibernatewithTomcat
why is that?

2. Do I have to use hibernate.properties file, or can I rename it to
x.properties and still use the content of the hibernate settings?


----- Original Message end (edited) ----

There's an example on how to configure Hibernate and Tomcat on the Tomcat Wiki. 
It's a bit old, but should still be valid.

http://wiki.apache.org/tomcat/TomcatHibernate

Hibernate does some nice things, such as making mapping between a relational 
database and objects easier, lazy loading, and loading classes through related 
tables into their proper classes. It also has interfaces to secondary caches 
(default is ehcache), which reduces the need to query a database for read-mostly 
information.

In some of the more complex uses, the Hibernate documents recommend using thread 
local variables and filters to manage Hibernate sessions. This can get a bit 
tricky if you're not careful.

You can do all of this manually with JNDI, some home-grown wrapper classes to 
manage relational-object mapping, and a caching implementation of your choice. 
However, Hibernate (or EclipseLink / JPA 2) makes doing this a bit easier.

Can a misconfigured Hibernate application cause users to be disconnected? 
Usually a misconfigured Hibernate application will refuse to start. Sometimes if 
your resource mapping is incorrect, the application will start, but those 
resources (and queries) will not function.

C3P0 pooling is the one included with Hibernate. Hibernate used to (2.x) include 
an interface to Apache DBCP, but this is no longer available in Hibernate 3.x. 
Thus, all of the pooling examples are written for C3P0.

You can use any file that is found on the classpath. However, the default is 
hibernate.cfg.xml. To change the default, change the following code from:

SessionFactory sf = new Configuration()
 .configure()
 .buildSessionFactory();

to:

SessionFactory sf = new Configuration()
 .configure("catdb.cfg.xml")
 .buildSessionFactory();

where "catdb.cfg.xml" is the name you've given to the file.

Further Hibernate questions are probably best answered on the Hibernate mailing 
lists or the Hibernate forum.

. . . . just my two cents

/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org