日期:2014-05-16 浏览次数:20453 次
package com.flysnow.domain.entity; import java.io.Serializable; /** * @author 飞雪无情 * @since:2010-2-20 */ /** * @hibernate.mapping default-lazy="false" * @hibernate.class table="t_person" * @hibernate.comment 人 */ public class Person implements Serializable { private static final long serialVersionUID = 6422096732289758030L; private Long id;//标识 private String name;//名字 private Integer age;//年龄 /** * @hibernate.id generator-class="native" * @hibernate.column name="ID" comment="标识" */ public Long getId() { return id; } public void setId(Long id) { this.id = id; } /** * @hibernate.property type="string" length="50" not-null="true" * @hibernate.column name="MZ"comment="名字" */ public String getName() { return name; } public void setName(String name) { this.name = name; } /** * @hibernate.property type="integer" not-null="true" * @hibernate.column name="NL" comment="年龄" */ public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } }
@hibernate.comment 人就是xdoclet2中对实体类的注释标记,而
@hibernate.column name="ID" comment="标识"则是对字段的注释标记,生成dll数据库脚本就是对表和列的注释说明。
<?xml version="1.0" encoding="UTF-8"?> <!-- ====================================================================== 2010-2-20 下午02:45:02 project description 飞雪无情 ====================================================================== --> <project name="project" default="generator-schema" basedir="."> <path id="build.lib"> <fileset dir="${basedir}/lib"> <include name="**/*.jar"/> </fileset> <fileset dir="${basedir}/lib/xdoclet"> <include name="**/*.jar"/> </fileset> <pathelement location="${basedir}/build/class"/> </path> <target name="complie" description="编译"> <javac srcdir="${basedir}/src" destdir="${basedir}/build/class"> <classpath refid="build.lib"></classpath> </javac> </target> <target name="generator-mapping" description="生成Mapping文件"> <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" classpathref="build.lib"></taskdef> <echo message="生成Mapping文件..."></echo> <xdocle