/** * 用户实体类 * * @hibernate.mapping default-cascade="true" * @hibernate.class table="TBL_USER" * */ public class User { private Integer id;// 用户编号 private String username;// 用户名 private String password;// 密码 public User() { super(); } public User(String username, String password) { super(); this.username = username; this.password = password; } /** * @hibernate.id generator-class="native" column="USER_ID" type="integer" * @return */ public Integer getId() { return id; } @SuppressWarnings("unused") private void setId(Integer id) { this.id = id; } /** * @hibernate.property column="UNAME" type="string" length="50" not-null="false" * @return */ public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } /** * @hibernate.property column="UPWD" type="string" length="50" not-null="false" * @return */ public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }build.xml文件
<?xml version="1.0" encoding="UTF-8"?> <project name="XDoclet-Hibernate" basedir="."> <!--后面的构建任务中可能会用到的一些基本属性--> <property name="project.lib.dir" value="${basedir}/lib" /> <property name="project.src.dir" value="${basedir}/src" /> <property name="xdoclet.home" value="E:/Jar/xdoclet-plugins-dist-1.0.4" /> <property file="hibernate.properties" /> <!-- =================================================================== --> <!-- Define the class path --> <!-- =================================================================== --> <path id="xdoclet.task.classpath"> <fileset dir="${xdoclet.home}/lib"> <include name="**/*.jar" /> </fileset> </path> <!-- 引用引入的jar包--> <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" classpathref="xdoclet.task.classpath" /> <!-- =================================================================== --> <!-- 生成Hibernate映射文件 --> <!-- =================================================================== --> <target name="gen-mapping"> <xdoclet> <fileset dir="${project.src.dir}"> <include name="**/*.java" /> </fileset> <component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin" version="3.0" destdir="${project.src.dir}" /> </xdoclet> </target> <!-- =================================================================== --> <!-- 生成Hibernate配置文件 --> <!-- =================================================================== --> <target name="gen-configuration"> <xdoclet> <fileset dir="${project.src.dir}"> <include name="**/*.java"/> </fileset> <component classname="org.xdoclet.plugin.hibernate.HibernateConfigPlugin" destdir="${project.src.dir}" version="3.0" hbm2ddlauto="create" jdbcurl="${hibernare.connection.url}" jdbcdriver="${hibernate.driver_class}" jdbcusername="${hibernate.connection.username}" jdbcpassword="${hibernate.connection.password}" dialect="${hibernate.dialect}" showsql="true" /> </xdoclet> </target> </project>
Hibernate实战_笔记19(实现映射之XDoclet),布布扣,bubuko.com
Hibernate实战_笔记19(实现映射之XDoclet)
原文:http://blog.csdn.net/com185272358/article/details/21230035