Hibernate Setup


This is based on previously setting up and documenting the addition of Hibernate to Java projects.

This attempt is part of exploring GWT's Request Factory.


  • Have a domain object I want to persist to a MySQL database.
  • The PointOfInterestSource is where much of the code will be held for supplying the PointOfInterestService.
  • I'd like to use the Hibernate Tool for Eclipse where possible.
  • I'd like to generate the DDL and table from an annotated class.


  1. Prepare Maven for Hibernate dependencies. It looks like I can follow the Maven Guide for Hibernate.
    1. Includes Maven Install (which I have)
    2. I'm using Java 6 (there used to be a restriction to use Java 5).
    3. Pasted in the recommended changes to the settings.xml (where is this now?) that allow the Hibernate plugins and repositories to be found.
    4. Manually added the following dependencies to the pom.xml for the project. Note that as of Dec 2011, these are the latest 3.x versions and not the 4.x versions.
  1. Added the Index to the JBoss (Hibernate) Repository //I'm leaving this step from a previous attempt, but I don't know how exactly how this is done. //
  1. Bring in Hibernate Tools for Eclipse unchecked because I already have these loaded.
    1. Using Eclipse to maintain versions of the Hibernate Tools (use Help -> Software Updates …) from within Eclipse and add a site for JBoss/Hibernate.
    2. Update Site is http://download.jboss.org/jbosstools/updates/stable
  2. Built up "Persistence" class (a bean)
    1. Created this shell of a class and added '@Entity" annotation.
    2. When resolving the dependency, I chose the javax.persistence.Entity package instead of the hibernate annotations package.
import javax.persistence.Entity;
import com.jettmarks.appname.server.PointOfInterestService;
 * These are the nodes on a Clue Route where a Key can be found to unlock the
 * Lock on the next set of clues.
 * @author jett
public class PointOfInterest
  1. The full section of annotated code is below
  /** Database representation of this entity. */
  Integer id;
  /** A word or two identifying the Point of Interest. */
  String name;
  /** Longer description of the Point of Interest. */
  String description;
  /** GeoLocation */
  double lat, lon;

Setup a DB connection

Generate a Configuration using the Hibernate Tool under Eclipse

  1. Open Hibernate Configurations window (Window -> Show View -> Other -> Hibernate)
  2. Right Click and then select "Add Configuration"
    1. Change name to mySql
    2. Type is Annotations
    3. Browse for project (listTags for initial pass)
    4. Create new Connection Create Eclipse DB Connection

Attempt to generate DDL

  • Should be able to use hbm2ddl tool.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License