download ,annatation and tools 两个项目。
添加相关的 jar.

<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="master.classpath" />

<target name="create_table">

<hibernatetool destdir="${script.dir}">
    <annotationconfiguration configurationfile="src/hibernate.cfg.xml" />
    <hbm2ddl export="false" create="true" delimiter=";" format="true" outputfilename="create-tables.sql" />
</hibernatetool>

</target>

<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory name="logi">
        <property name="show_sql">true</property>
        <mapping class="com.tt.logi.target.Target"/>
   
    </session-factory>
</hibernate-configuration>

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Target implements Serializable{
   
    private Long id;
    private String name;
    @Id
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @Basic
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
   
   
   



西津渡