Monday, November 07, 2005

Hibernate, quick start guide

What is Hibernate?
Hibernate is a ORM tool. ORM means object relational mapping. In laymans term, you can have a bunch of java classes(Value objects) and expect them to map directly on to the tables\columns in the database.

What can we do with Hibernate?
Lots of things. You can design the object layer and forget about your relational layer. You can create both relational and object layers and forget about data transportation.

How does Hibernate work?
By now you might have realized that the major component in hibernate or any other ORM for that matter is "M", "M" for mapping. Your task is to generate/create this mapping file. And then compile everything. So basically, you create the object layer, create a blank database, create a mapping file, create a property file with database details and command the hibernate libraries to do the mapping. You can then use the hibernate libraries in your code to play around with your objects, that are mapped on to the database.

Getting started:
  • "Road to Hibernate" is an excellent tutorial for you to get started with Hibernate. Here is the brief summary of what you will be doing:
  • Download and install hibernate(c:\program files\hibernate-3_0_5)
  • set up a work folder, something like c:\dev\hibernate
  • Copying\referencing a bunch of \lib files: ant-antlr-1.6.3.jar, asm.jar, cglib-2.1.jar, commons-collections-2.1.1.jar, commons-logging-1.0.4.jar, dom4j-1.6.jar, hibernate3.jar, jdbc2_0-stdext.jar, jta.jar, jtds-1.1.jar, log4j-1.2.9.jar
  • Create some java value objects as described in the article.
  • Create mapping file: hbm.xml
  • Create a configuration file with db connection information: hibernate.cfg.xml
  • Write code, build and execute.
The Road to Hibernate is an introductory tutorial for new users of Hibernate. We start up with a simple command line application using an in-memory database and develop it further in small steps, until we reach a full fledged J2EE-Application using Hibernate, EJBs, XDoclet and all the other nifty stuff.

This tutorial is intended to be for beginning users of Hibernate, but with advanced Java knowledge. It increases slowly in speed


@link

0 Comments:

Post a Comment

<< Home