HomeHome  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  

Share | 
 

 Getting started with Hibernate

Go down 
AuthorMessage
sojan

avatar

Number of posts : 29
Age : 34
Registration date : 2007-03-04

PostSubject: Getting started with Hibernate   Thu Mar 08, 2007 10:57 am

This tutorial explains a setup of Hibernate 2.1 with the Apache Tomcat servlet container for a web-based application. Hibernate works well in a managed environment with all major J2EE application servers, or even in standalone Java applications. The database system used in this tutorial is PostgreSQL 7.3, support for other database is only a matter of changing the Hibernate SQL dialect configuration.

First, we have to copy all required libraries to the Tomcat installation. We use a separate web context (webapps/quickstart) for this tutorial, so we've to consider both the global library search path (TOMCAT/common/lib) and the classloader at the context level in webapps/quickstart/WEB-INF/lib (for JAR files) and webapps/quickstart/WEB-INF/classes. We refer to both classloader levels as the global classpath and the context classpath.

Now, copy the libraries to the two classpaths:

Copy the JDBC driver for the database to the global classpath. This is required for the DBCP connection pool software which comes bundled with Tomcat. Hibernate uses JDBC connections to execute SQL on the database, so you either have to provide pooled JDBC connections or configure Hibernate to use one of the directly supported pools (C3P0, Proxool). For this tutorial, copy the pg73jdbc3.jar library (for PostgreSQL 7.3 and JDK 1.4) to the global classloaders path. If you'd like to use a different database, simply copy its appropriate JDBC driver.

Never copy anything else into the global classloader path in Tomcat, or you will get problems with various tools, including Log4j, commons-logging and others. Always use the context classpath for each web application, that is, copy libraries to WEB-INF/lib and your own classes and configuration/property files to WEB-INF/classes. Both directories are in the context level classpath by default.

Hibernate is packaged as a JAR library. The hibernate2.jar file should be copied in the context classpath together with other classes of the application. Hibernate requires some 3rd party libraries at runtime, these come bundled with the Hibernate distribution in the lib/ directory.
Back to top Go down
View user profile http://sojanctherakom.googlepages.com
 
Getting started with Hibernate
Back to top 
Page 1 of 1
 Similar topics
-
» Migraines and Working Out Fear
» Ironing started my head off.,
» anyone tried seroquel for migraines?
» Selenium webdriver Error - "Could not contact Selenium Server".
» Getting started, need some advice?

Permissions in this forum:You cannot reply to topics in this forum
 :: Programming Languages :: JAVA-
Jump to: