Java
  Home arrow Java arrow Adding Hibernate to a Java Application
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

Adding Hibernate to a Java Application
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2006-11-30

    Table of Contents:
  • Adding Hibernate to a Java Application
  • Hibernate Mappings for Existing Domain Objects
  • Changing the Application Configuration
  • Spring’s Built-In Hibernate Support

  • 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


    Adding Hibernate to a Java Application


    (Page 1 of 4 )

    This article concludes our discussion covering the addition of a search service to a Java application. It is excerpted from chapter 10 of the book Better, Faster, Lighter Java, written by Bruce A. Tate and Justin Gehtland (O'Reilly; ISBN: 0596006764).

    Adding Hibernate

    jPetStore uses a relatively straightforward architecture for providing database access. There is an interface layer that provides functional mapping to the DAOs themselves without worrying about actual implementation details. The specific DAOs vary based on the backend database; we’ll be examining the ones targeting HSQLDB (Hypersonic SQL).

    Existing Architecture

    Let’s look at how the Product class is managed. Product is the domain object that represents one item in the catalog.

    Product is the domain object that represents one item in the catalog.class is managed. Product is the domain object that represents one item in the catalog.Product class is managed. Product is the domain object that represents one item in the catalog.Let’s look at how the Product class is managed. Product is the domain object that represents one item in the catalog.

      package org.springframework.samples.jpetstore.domain;
      import java.io.Serializable;
      public class Product implements Serializable {

        private String productId;
        private String categoryId;
        private String name;
        private String description;

        public String getProductId() { return productId; }
        public void setProductId(String productId) { this.productId = productId.trim(); }

        public String getCategoryId() { return categoryId; }
        public void setCategoryId(String categoryId) { this.categoryId = categoryId; }

        public String getName() { return name; }
        public void setName(String name) { this.name = name; }

        public String getDescription() { return description; }
        public void setDescription(String description) { this.description = description;}

        public String toString() {
          return getName();
        } 

      }

    Its persistence is managed through an object that implements theProductDaointerface. AProductDao must be able to load a specific product given its ID, or load a list of products either from a category or from a set of keywords.

      public interface ProductDao {

        List getProductListByCategory(String categoryId) throws DataAccessException;
        List searchProductList(String keywords) throws DataAccessException;
        Product getProduct(String productId) throws DataAccessException;

      }

    There currently exists a class calledSqlMapProductDao that looks up product information in Hypersonic SQL through SQL mapping files.

    More Java Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Better, Faster, Lighter Java," published...
     

    Buy this book now. This article is excerpted from the book Better, Faster, Lighter Java, written by Bruce A. Tate and Justin Gehtland (O'Reilly; ISBN: 0596006764). 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 1 Hosted by Hostway
    Stay green...Green IT