I am trying to generate sql using ANT script, i am not getting any errors and its generating empty sql file. Could someone please check,
My Java bean is,
Code:
import org.hibernate.annotations.Entity;
import javax.persistence.Column;
import javax.persistence.Version;
@Entity
public class Profile implements Serializable
{
private String name;
@Version
@Column
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
My ant script is,
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="pa" basedir="." default="package">
<property file="build.properties" />
<property name="project.title" value="SVP Training Emulation Module" />
<property name="project.distname" value="pa" />
<property name="project.version" value="1.00.05" />
<property name="war.dir" value="${dist.dir}/${project.distname}" />
<property name="war.classes.dir" value="${war.dir}/WEB-INF/classes" />
<target name="package">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath refid="hibernate-tools" />
</taskdef>
<hibernatetool destdir="${dist.dir}">
<classpath>
<path location="${bin.dir}" />
<path location="${lib.dir}" />
</classpath>
<annotationconfiguration configurationfile="${bin.dir}/pa/hibernate/pa.hibernate.cfg.xml" />
<hbm2ddl outputfilename="test.sql" format="true" export="false" drop="true"/>
</hibernatetool>
</target>
<path id="hibernate-tools">
<path location="${bin.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${lib.dir}/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
</project>
My build.properties,
Code:
appname=pa
# This must match the name in the WSDL file
servicename=TBD
# Change this to reflect the webapps directory of your application server
webapps.dir=/pa/apache-tomcat-6.0.18/webapps
src.dir=../src/main/java
codegen.dir=codegen
schema.dir=../src/main/resources/schemas
bin.dir=../web/WEB-INF/classes
lib.dir=../web/WEB-INF/lib
conf.dir=../src/main/resources
dist.dir=../target
webroot.dir=../web
xdoclet.lib.dir=assets/lib/xdoclet2
servletapi.lib=/pa/apache-tomcat-6.0.18/lib/servlet-api.jar
package=
wsdlfile=
aarfile=
# The properties below are used by build.xml to deploy web services. Specify
# the hostname and port of the system you are deploying web services to.
hostname=localhost
port=8080
sslport=8443
and my hibernate config file is,
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost/pa;SendStringParametersAsUnicode=false</property>
<property name="hibernate.connection.username">myuser</property>
<property name="hibernate.connection.password">mypass</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.pa.beans.contact.Profile"/>
</session-factory>
</hibernate-configuration>
Output form ANT,
Code:
Apache Ant version 1.7.1 compiled on June 27 2008
Buildfile: C:\pa\dev\pa\build\build.xml
parsing buildfile C:\pa\dev\pa\build\build.xml with URI = file:/C:/pa/dev/pa/build/build.xml
Project base dir set to: C:\pa\dev\pa\build
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
[property] Loading C:\pa\dev\pa\build\build.properties
Build sequence for target(s) `package' is [package]
Complete build sequence is [package, ]
package:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
BUILD SUCCESSFUL
Total time: 1 second
Thank you,
Sam