Java
  Home arrow Java arrow Page 5 - Installation and Set Up of Hibernate
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Installation and Set Up of Hibernate
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 7
    2006-07-27

    Table of Contents:
  • Installation and Set Up of Hibernate
  • Getting an Ant Distribution
  • Getting the HSQLDB Database Engine
  • Getting Hibernate
  • Setting Up a Project Hierarchy
  • Setting Up a Project Hierarchy: A quick test

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Installation and Set Up of Hibernate - Setting Up a Project Hierarchy


    (Page 5 of 6 )

    Although we’re going to start small, once we start designing data structures and building Java classes and database tables that represent them, along with all the configuration and control files to glue them together and make useful things happen, we’re going to end up with a lot of files. So let’s start out with a good organization from the beginning. As you’ll see in this process, between the tools you’ve downloaded and their supporting libraries, there are already a significant number of files to organize.

    Why do I care?

    If you end up building something cool by following the examples in this book, and want to turn it into a real application, you’ll be in good shape from the beginning. More to the point, if you set things up the way we describe here, the commands and instructions we give you throughout the examples will make sense and actually work. Many examples alsobuild on one another throughout the book, so it’s important to get on the right track from the beginning.

    If you want to skip ahead to a later example, or just avoid typing some of the longer sample code and configuration files, you can download “finished” versions of the chapter examples from the book’s web site. These downloads will all be organized as described here.

    How do I do that?

    Here's how:

    1. Pick a location on your hard drive where you want to play with Hibernate, and create a new folder, which we’ll refer to from now on as your project directory
    2. Move into that directory, and create subdirectories calledsrc,lib, anddata. The hierarchy of Java source and related resources will be in thesrc directory. Our build process will compile it into aclasses directory it creates, as well as copy any runtime resources there. Thedata directory is where we’ll put the HSQLDB database, and any Data Definition Language (DDL) files we generate in order to populate it.

      Thelib directory is where we’ll place third-party libraries we use in the project. For now, copy the HSQLDB and Hibernate JAR files into thelib directory.
    3. If you haven’t already done so, expand the HSQLDB distribution file you downloaded earlier in this chapter. You’ll findhsqldb.jar in itslib directory; copy this to your own projectlib directory (thelib directory you just created in step 2).
    4. Similarly, locate thelib directory in the Hibernate directory you expanded in the previous section, and copy all of its contents into your own projectlib directory (you’ll notice that Hibernate relies on a lot of other libraries; conveniently, they’re included in its binary distribution so you don’t have to hunt them all down yourself). 
    5. Then copy Hibernate itself, in the form of thehibernate2.jar file found at the top level of the distribution, into your projectlib directory. 
    6.  Installing the Hibernate Extensions is very similar. Locate thetools/lib directory inside the Hibernate Extensions directory you expanded, and copy its contents into your ownlib directory, so the extensions will be able to access the libraries they rely on.
    7. Finally, copy the extensions themselves, which are in the filehibernate-tools.jar (found in thetools directory), into yourlib directory.

      There are lots of pieces to copy into place here; attention to detail will be rewarded. Luckily, you can reuse your lib directory in other Hibernate projects.

    8. The example classes we’re going to create are all going to live in thecom.oreilly.hh (harnessing Hibernate) package, so create these directories under thesrc directory. On Linux and Mac OS X, you can use:

        mkdir -p src/com/oreilly/hh

      from within your project directory to accomplish this in one step.

      At this point your project directory should be structured as shown in Figure 1-1.

              
      Figure 1-1.  Initial project directory contents

    The lib directory is collapsed because it contains so much that the screen shot wouldn’t fit otherwise. After following the above steps, using the release of Hibernate available at the time of this writing, it contains the following files:

    README.txt, ant-1.5.3.jar, ant-optional-1.5.3.jar, apache.license.txt, c3p0-
    0.8.3.jar, c3p0.license.txt, cglib-2.0-rc2.jar, commons-collections-2.1.jar,
    commons-dbcp-1.1.jar, commons-lang-1.0.1.jar, commons-logging-1.0.3.jar, commons-pool-1.1.jar, concurrent-1.3.2.jar, connector.jar, connector. licence.txt, dom4j-1.4.jar, ehcache-0.6.jar, hibernate-tools.jar, hibernate2.jar, hsqldb.jar, jaas.jar, jaas.licence.txt, jboss-cache.jar, jboss-common.jar, jboss-jmx.jar, jboss-system.jar, jcs-1.0-dev.jar, jdbc2_0-
    stdext.jar, jdbc2_0-stdext.licence.txt, jdom.jar, jdom.license.txt, jgroups-
    2.2.jar, jta.jar, jta.licence.txt, junit-3.8.1.jar, log4j-1.2.8.jar, odmg-3.
    0.jar, oscache-2.0.jar, proxool-0.8.3.jar, swarmcache-1.0rc2.jar, xalan-2.4.
    0.jar, xerces-2.4.0.jar, xml-apis.jar.

    More Java Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Hibernate A Developer's Notebook,"...
       · here you can find nice video tutorial how to set up...
     

    Buy this book now. This article is excerpted from chapter one of Hibernate A Developer's Notebook, written by James Elliot (O'Reilly; ISBN: 0596006969). Check it out today at your favorite bookstore. Buy this book now.

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek