I did an:
Code:
ant -v schema-export
and got a message about duplicate class/entity. I tweaked my build.xml so it matched the successful one I used for
Hibernate Quickly examples, and now there's no error. In fact, it says:
Quote:
jon$ ant schema-export
Buildfile: build.xml
init:
[mkdir] Created dir: /Users/jon/jbproject/wp/build/classes
compile:
[javac] Compiling 2 source files to /Users/jon/jbproject/wp/build/classes
schema-export:
[schemaexport] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.
BUILD SUCCESSFUL
Total time: 3 seconds
MacbookPro:~/jbproject/wp jon$
but
nothing is done in the database and nothing is written to schema-export.sql. I am really stumped because the practically identical setup in a parallel directory works just fine.
build.xml:
Code:
<?xml version="1.0"?>
<project name="build.xml" default="build">
<property name="src.java.dir" location="src/java" />
<property name="build.classes.dir" location="build/classes" />
<property name="hibernate.version" value="3.2" />
<property name="mysql.jdbc.version" value="5.0.4" />
<property name="hibernate.lib.dir" location="/usr/local/hibernate-${hibernate.version}" />
<property name="jdbc.driver.jar" location="/usr/local/mysql-connector-java-${mysql.jdbc.version}/mysql-connector-java-${mysql.jdbc.version}-bin.jar" />
<property name="hibernate.tools.dir" location="${hibernate.lib.dir}/lib" />
<import file="hibernate-build.xml" />
<path id="project.classpath">
<pathelement location="${build.classes.dir}" />
<pathelement location="${jdbc.driver.jar}" />
<path refid="hibernate.lib.path" />
<pathelement location="${hibernate.tools.dir}" />
</path>
<path id="runtime.classpath">
<path refid="project.classpath" />
<path refid="hibernate.lib.path" />
<pathelement location="${jdbc.driver.jar}" />
<pathelement location="${src.java.dir}" />
</path>
<target name="clean">
<delete dir="${build.classes.dir}" />
</target>
<target name="init">
<mkdir dir="${build.classes.dir}" />
</target>
<target name="compile" depends="init" >
<javac srcdir="${src.java.dir}" destdir="${build.classes.dir}">
<classpath refid="hibernate.lib.path" />
</javac>
</target>
<target name="build" depends="compile" >
</target>
<target name="schema-export" depends="compile" >
<taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath refid="runtime.classpath" />
</taskdef>
<schemaexport config="${src.java.dir}/hibernate.cfg.xml" output="schema-export.sql" />
</target>
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" />
<target name="codegen" description="Generate Java source from the O/R mapping files">
<hibernatetool destdir="${src.java.dir}">
<configuration>
<fileset dir="${src.java.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<hbm2java />
</hibernatetool>
</target>
</project>
hibernate-build.xml:
Code:
<?xml version="1.0"?>
<project name="hibernate-build.xml" default="build">
<path id="hibernate.lib.path">
<fileset dir="${hibernate.lib.dir}/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${hibernate.lib.dir}">
<include name="hibernate3.jar" />
</fileset>
</path>
<target name="default" />
</project>
hibernate.cfg.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.url">
jdbc:mysql://localhost/wp
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="com/snoopjonny/wp/hibernate/Item.hbm.xml" />
</session-factory>
</hibernate-configuration>
Item.hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.snoopjonny.wp.hibernate">
<class name="Item" table="item">
<id name="id" column="id" type="int">
<generator class="native" />
</id>
<property name="code" type="string" />
<property name="type" type="string" />
<property name="title" type="string" />
<property name="description" type="text" />
<property name="price" type="big_decimal" />
<property name="taxable" type="string" />
<property name="date_added" type="timestamp" />
</class>
</hibernate-mapping>
Any help is appreciated. THANKS!
-Jon