Can anyone get org.hibernate.tool.ant.HibernateToolTask to export-schema into MySql ?
I'm using netbeans and ant.
it's worth noting that the tutorial in the doc folder with the hibernate download
( main site) works by merely including
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
in the hibernate cfg file for some reason...
retrying with this setup..
build.xml:
<project name="hibernate_eventMgr" default="compile">
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/classes"/>
<property name="lib.dir" value="C:/jars/"/>
<property name="hibernate.version" value="3.0"/>
<property name="mysql.jdbc.version" value="5.0.7"/>
<path id="libraries">
<fileset dir="${lib.dir}">
<include name="hibernate/*.jar"/>
<include name="dbasecon/mysql-connector-java-5.0.7-bin.jar"/>
<include name="logging/*.jar"/>
<include name="testing/junit/junit-4.4.jar"/>
</fileset>
</path>
<path id="toolslib">
<path location="${lib.dir}/hib-tools/hibernate-tools.jar" />
<path location="${lib.dir}/logging/commons-logging-1.0.4.jar" />
<path location="${lib.dir}/logging/dom4j-1.6.1.jar" />
<path location="${lib.dir}/hibernate/hibernate3.jar" />
<path location="${lib.dir}/hib-tools/freemarker.jar" />
<path location="${lib.dir}/dbasecon/mysql-connector-java-5.0.7-bin.jar" />
</path>
<path id="project.classpath">
<pathelement location="${build.dir}" />
</path>
<path id="runtime.classpath">
<path refid="project.classpath"/>
<path refid="libraries"/>
<pathelement location="${jdbc.driver.jar}"/>
<pathelement location="${src.dir}"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="clean, copy-resources">
<javac srcdir="${src.dir}"
destdir="${build.dir}"
classpathref="libraries"/>
<copy todir="${build.dir}">
<fileset dir="${src.dir}" >
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<target name="copy-resources">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="run" depends="compile">
<java fork="true" classname="com.manning.hq.ch04.EventLoader" classpathref="${lib.dir}/hibernate/*.jar">
<classpath path="${build.dir}"/>
</java>
<echo>If you see this, it works!!!${build.dir}</echo>
</target>
<!-- off the main site -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />
<target name="schema-drop" depends="compile">
<hibernatetool destdir="${build.dir}">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2ddl drop="true" create="false" export="true" update="false"/>
</hibernatetool>
</target>
<target name="schema-recreate" depends="compile">
<hibernatetool destdir="${build.dir}">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2ddl drop="true" create="true" export="true" update="false"/>
</hibernatetool>
</target>
<target name="schema-docu" depends="compile" description="Generate a html description of the mappings">
<hibernatetool destdir="hibernate-html">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2doc/>
</hibernatetool>
</target>
</project>
my hibernate.cfg.xml:
<project name="hibernate_eventMgr" default="compile">
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/classes"/>
<property name="lib.dir" value="C:/jars/"/>
<property name="hibernate.version" value="3.0"/>
<property name="mysql.jdbc.version" value="5.0.7"/>
<path id="libraries">
<fileset dir="${lib.dir}">
<include name="hibernate/*.jar"/>
<include name="dbasecon/mysql-connector-java-5.0.7-bin.jar"/>
<include name="logging/*.jar"/>
<include name="testing/junit/junit-4.4.jar"/>
</fileset>
</path>
<path id="toolslib">
<path location="${lib.dir}/hib-tools/hibernate-tools.jar" />
<path location="${lib.dir}/logging/commons-logging-1.0.4.jar" />
<path location="${lib.dir}/logging/dom4j-1.6.1.jar" />
<path location="${lib.dir}/hibernate/hibernate3.jar" />
<path location="${lib.dir}/hib-tools/freemarker.jar" />
<path location="${lib.dir}/dbasecon/mysql-connector-java-5.0.7-bin.jar" />
</path>
<path id="project.classpath">
<pathelement location="${build.dir}" />
</path>
<path id="runtime.classpath">
<path refid="project.classpath"/>
<path refid="libraries"/>
<pathelement location="${jdbc.driver.jar}"/>
<pathelement location="${src.dir}"/>
</path>
<target name="clean">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="clean, copy-resources">
<javac srcdir="${src.dir}"
destdir="${build.dir}"
classpathref="libraries"/>
<copy todir="${build.dir}">
<fileset dir="${src.dir}" >
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<target name="copy-resources">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="run" depends="compile">
<java fork="true" classname="com.manning.hq.ch04.EventLoader" classpathref="${lib.dir}/hibernate/*.jar">
<classpath path="${build.dir}"/>
</java>
<echo>If you see this, it works!!!${build.dir}</echo>
</target>
<!-- off the main site -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />
<target name="schema-drop" depends="compile">
<hibernatetool destdir="${build.dir}">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2ddl drop="true" create="false" export="true" update="false"/>
</hibernatetool>
</target>
<target name="schema-recreate" depends="compile">
<hibernatetool destdir="${build.dir}">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2ddl drop="true" create="true" export="true" update="false"/>
</hibernatetool>
</target>
<target name="schema-docu" depends="compile" description="Generate a html description of the mappings">
<hibernatetool destdir="hibernate-html">
<configuration configurationfile="${build.dir}/hibernate.cfg.xml" />
<hbm2doc/>
</hibernatetool>
</target>
</project>
now gives this error:
clean:
Deleting directory C:\Documents and Settings\John Okrasa.ANTENNA\My Documents\NetBeansProjects\hibernate_eventMgr\classes
Created dir: C:\Documents and Settings\John Okrasa.ANTENNA\My Documents\NetBeansProjects\hibernate_eventMgr\classes
copy-resources:
Copying 6 files to C:\Documents and Settings\John Okrasa.ANTENNA\My Documents\NetBeansProjects\hibernate_eventMgr\classes
compile:
Compiling 3 source files to C:\Documents and Settings\John Okrasa.ANTENNA\My Documents\NetBeansProjects\hibernate_eventMgr\classes
schema-recreate:
Executing Hibernate Tool with a Standard Configuration
1. task: hbm2ddl (Generates database schema)
An exception occurred while running exporter #2:hbm2ddl (Generates database schema)
To get the full stack trace run ant with -verbose
org.hibernate.MappingNotFoundException: resource: com/manning/hq/ch04/Event.hbm.xml not found
A resource located at com/manning/hq/ch04/Event.hbm.xml was not found.
Check the following:
1) Is the spelling/casing correct ?
2) Is com/manning/hq/ch04/Event.hbm.xml available via the classpath ?
3) Does it actually exist ?
org.hibernate.MappingNotFoundException: resource: com/manning/hq/ch04/Event.hbm.xml not found
classpath,classpath,... I checked it thoroughly... why can't it see it ???
|