Hibernate Tools
References
- Hibernate Tools for Eclipse and Tutorials
- The tools are loaded into Eclipse using their update site: http://tools.jboss.org/downloads/jbosstools/luna/4.2.2.Final.html (old: http://download.jboss.org/jbosstools/updates/stable/galileo/)
- This led me to the Data Source configuration portion of Eclipse. I didn't actually get one setup until I went through getting this to work.
Setup
Overview
- The tools provide a number of features. This focuses on:
- Defining and configurating the database through Annotations as much as practical
- The console which allows viewing the configuration and the database tables
- Generating DDL using an Ant task (to be moved under Maven)
- Getting feedback on Annotated persistence classes is covered under Hibernate Annotation Dev
Depends On (updated Feb. 2015 for Luna)
- JDK 7
- Eclipse 4.4 (Luna) +
Steps
- Follow Hibernate Tools Install for Eclipse. This uses the Eclipse Update Software feature.
- Create Hibernate Console Configuration to allow checking/editing the config.
- Setup a build.xml for generating DDL:
<?xml version="1.0" encoding="UTF-8"?> <project name="GenDDL" default="default" basedir="."> <path id="toolslib"> <path location="N:\hibernate-3.2\lib\dom4j-1.6.1.jar" /> <path location="N:\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar" /> <path location="M:\\download\\hibernate-tools-3.2.0.beta8.jar" /> <path location="N:\.m2\repository\org/hibernate\hibernate\3.2.6.ga/hibernate-3.2.6.ga.jar" /> <path location="N:\hibernate-annotations-3.3.1.GA\lib\hibernate-commons-annotations.jar" /> <path location="N:\.m2\repository\hibernate-annotations\hibernate-annotations\3.3.1.GA_CP01-brew\hibernate-annotations-3.3.1.GA_CP01-brew.jar" /> <path location="N:\.m2\repository\javax\persistence\persistence-api\1.0\persistence-api-1.0.jar" /> <path location="N:\hibernate-3.2\lib\commons-collections-2.1.1.jar" /> <path location="N:\.m2\repository\mysql\mysql-connector-java\3.1.14\mysql-connector-java-3.1.14.jar" /> <!-- <path location="lib/freemarker.jar" /> <path location="${jdbc.driver.jar}" /> --> </path> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="toolslib" /> <target name="default"> <hibernatetool destdir="target/sql/"> <classpath> <path location="." /> <path location="target/listTags-1.0-SNAPSHOT/WEB-INF/classes" /> </classpath> <annotationconfiguration configurationfile="hibernate.cfg.xml"/> <hbm2ddl outputfilename="listTags.ddl" format="true"/> </hibernatetool> </target> </project>
page revision: 26, last edited: 18 Feb 2015 02:13