xdoclet2 例子

Customer.java
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->package org.roadway.wisp.test;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;

/**
 * @hibernate.class table="ZD_COSTOMER"
 
*/
public class Customer implements Serializable
{
    
private static final long serialVersionUID = 939548333216539319L;
    
    
private Long              customerId;
    
    
private String            customerName;
    
    
private Date              birthday;
    
    
private HashSet<Order>    orders;
    
    
/**
     * @hibernate.id generator-class="sequence" column="CUSTOMER_ID"
     *               unsaved-value = "null"
     * @hibernate.generator-param name="sequence" value="SQ_PERSON_ID"
     * 
     * 
@return
     
*/
    
public Long getCustomerId()
    {
        
return customerId;
    }
    
    
/**
     * @hibernate.property column="CUSTOMER_NAME" length="32" not-null="true"
     
*/
    
public String getCustomerName()
    {
        
return customerName;
    }
    
    
/**
     * @hibernate.property column="BIRTHDAY"
     
*/
    
public Date getBirthday()
    {
        
return birthday;
    }
    
    
/**
     * @hibernate.set table="ZD_ORDER" lazy="true" inverse="true"
     * @hibernate.key column="CUSTOMER_ID"
     * @hibernate.one-to-many class="org.roadway.wisp.test.Order"
     
*/
    
public HashSet<Order> getOrders()
    {
        
return orders;
    }
    
    
public void setCustomerId(Long customerId)
    {
        
this.customerId = customerId;
    }
    
    
public void setCustomerName(String customerName)
    {
        
this.customerName = customerName;
    }
    
    
public void setBirthday(Date birthday)
    {
        
this.birthday = birthday;
    }
    
    
public void setOrders(HashSet<Order> orders)
    {
        
this.orders = orders;
    }
}
Order.java
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->package org.roadway.wisp.test;

import java.io.Serializable;

/**
 * @hibernate.class table="ZD_ORDER"
 
*/
public class Order implements Serializable
{
    
private static final long serialVersionUID = 8989273619109202636L;
    
    
private Long              orderId;
    
    
private String            orderName;
    
    
private Double            money;
    
    
private Customer          customer;
    
    
/**
     * @hibernate.id generator-class="sequence" column="ORDER_ID" unsaved-value =
     *               "null"
     * @hibernate.generator-param name="sequence" value="SQ_ORDER_ID"
     * 
     * 
@return
     
*/
    
public Long getOrderId()
    {
        
return orderId;
    }
    
    
/**
     * @hibernate.property column="ORDER_NAME" length="32" not-null="true"
     
*/
    
public String getOrderName()
    {
        
return orderName;
    }
    
    
/**
     * @hibernate.property column="MONEY" not-null="true"
     
*/
    
public Double getMoney()
    {
        
return money;
    }
    
    
/**
     * @hibernate.many-to-one column="teacher_id" not-null="true"
     
*/
    
public Customer getCustomer()
    {
        
return customer;
    }
}
xdoclet.xml
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><?xml version="1.0"?>
<project name="xdoclet" default="hibernate.mapping.generate" basedir=".">
    
<property name="project.src" value="test"/>
    
<property name="po.package" value="org/roadway/wisp/test"/>
    
<property name="xdoclet.lib" value="E:/user_hvp/xdoclet-plugins-dist-1.0.4/lib"/>
    
<path id="xdoclet.task.classpath">
        
<fileset dir="${xdoclet.lib}">
            
<include name="*.jar" />
        
</fileset>
        
<pathelement location="${xdoclet.lib}/xdoclet-plugin-hibernate-1.0.4.jar" />
    
</path>
    
<taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" classpathref="xdoclet.task.classpath" />
    
<target name="hibernate.mapping.generate">
        
<xdoclet>
            
<fileset dir="${project.src}">
                
<include name="${po.package}/*.java" />
            
</fileset>
            
<component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin" destdir="${basedir}/${project.src}" version="3.0" />
        
</xdoclet>
    
</target>
</project>
xdoclet1.x不支持泛型,xdoclet2支持!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值