Hmmm, where to start....
Let's start with the JAR: HibernateN.jar (where N is the version number). Drop this in your lib folder.
You're probably going to need to select a bunch of supporting JARs to go with Hibernate, depending on what options you want. For example:
hsqldb.jar if you want to develop the app in a memory database
c3p0.jar if you want connection pooling
cglib.jar is normally required with Hibernate
ehcache.jar if you want to use this caching option
jdbc.jar is required to do the connection to the database
mysql.jar or oracle.jar or whatever your database is
Is Hibernate a good choice? Yes
The basic things to start an application? Hmmm, a stand-alone application. Okay, you've probably read about the XML configuration file - looks a little like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="myapp">
<class name="Customer" table="app_customer">
<id name="id" type="integer">
<generator class="identity" />
</id>
<property name="name" type="string" />
<list name="orders" cascade="all-delete-orphan">
<key column="_customer" />
<list-index column="order_no" />
<one-to-many class="Order" />
</list>
</class>
</hibernate-mapping>
You also need a Hibernate context XML document. This defines your database (or connection pool) and the XML configuration file you are going to use:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<description>Configuration of context beans</description>
<bean id="sessionFactory" class="org.hibernate3.SessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingDirectoryLocations">
<value>conf/hbm</value>
</property>
<property name="hibernateProperties">
<props>
<!-- Dialect to use -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop -->
<!-- isolation level TRANSACTION_READ_UNCOMMITTED -->
<prop key="hibernate.connection.isolation">1</prop>
<!-- enable query caching -->
<prop key="hibernate.cache.use_query_cache">true</prop>
<!-- standard hibernate properties -->
<prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.use_get_generated_keys">false</prop>
<prop key="hibernate.jdbc.fetch_size">25</prop>
<!--<prop key="hibernate.jdbc.batch_size">0</prop>-->
<prop key="hibernate.jdbc.use_streams_for_binary">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
</props>
</property>
<!-- Creates/updates the db schema automatically -->
<property name="schemaUpdate" value="true"/>
</bean>
<!-- ==================== Data Source Definitions =========================== -->
<!-- Mysql config -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydbnm"/>
<property name="user" value="myusername"/>
<property name="password" value="mypassw0rd"/>
</bean>
<!--
<!- - HSql config - - >
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="org.hsqldb.jdbcDriver"/>
<property name="jdbcUrl" value="jdbc:hsqldb:mem:testdb"/>
<property name="user" value="myusername"/>
<property name="password" value="mypassw0rd"/>
</bean>
-->
</beans>
Then you start coding your application.
A really good place to start is the Caveat Emptor example Hibernate application. See
http://www.hibernate.org/400.html
Let us know how you go with this information...
Cheers
mc